Joerg Heinicke dijo:
> On 18.04.2004 10:17, Jaroslav Kuruc wrote:
>
>>>> The problem is when I want to generate text which will be showed in
>>>> javascript alert. When it contains entity representation of the
>>>> characters, text in the message box is escaped and the entity
>>>> representation is showed. At least in the IE.
>>
>> The point is, browser doesn't understand entities in JS. Try this:
>>
>> <html>
>> <body>
>> <script type="text/javascript" language="JavaScript">
>> alert('&Aacute;');
>> </script>
>> </body>
>> </html>
>
> That's true(ly a problem). I don't know if it is a spec issue, at least
> I don't understand why the script part is not parsed in the same way
> like the HTML itself. It's only read as text. The only solution I know
> is to separate the JavaScript into external files.

I think it is a specification issue:
http://www.w3.org/TR/2004/REC-xml-20040204/#syntax

<snip>
The ampersand character (&) and the left angle bracket (<) MUST NOT appear
in their literal form
</snip>

In that way we must to use:

<script type="text/javascript" language="JavaScript">
  alert(&apos;&amp;Aacute;&apos;);
</script>

What clearly is very wird! Another solution is to use CDATA, but try to
avoid it. This is why I prefer a separated javascript file.

Best Regards,

Antonio Gallardo


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to