Craig Jurney wrote:
[color=blue]
> kaeli wrote:[color=green]
>> [...]
snorlaxnet@hotmail.com enlightened us with...
>> That said, I seem to recall a problem with document.write and writing the
>> tag "</script>"
>> I think you need to split it, like
>> document.write("</scr"+"ipt>");
>> Something about the parser interpreting it as a real </script>...?[/color]
>
> Exactly so. Cf. David Flanagan's "JavaScript, the Definitive Guide"
> 12.2.1.2 [p.214, 3rd Ed.], [p.188, 4th Ed.]
>
> "...[T]he HTML parser makes make no attempt to understand your[/color]
^^^^^^^^^^^[color=blue]
> JavaScript code, and if it sees the string "</script>" in your code,
> even if it appears within quotes, it assumes that it has found the
> closing tag of the currently running script."[/color]
However, Flanagan is wrong again. If we are talking about HTML parsers
(and not those tag soup parsers implemented in desktop Web browsers),
`"</scr" + "ipt>"' and the like won't help. With a (strict) HTML parser,
it is the ETAGO (End Tag Open) delimiter (`</') within the script that
causes the problem. The `script' element contains CDATA (character data),
and an SGML compliant parser, as a strict HTML parser would be, parsers
CDATA content up to the ETAGO delimiter. That is why the script engine is
passed incomplete and therefore syntactical incorrect code.
cwdjrxyz@yahoo.com pointed out the correct solution for source code of
ECMAScript compliant languages included in HTML documents. Yet the reason
why the W3C Markup Validator "grumbles" at the ETAGO delimiter is that an
SGML compliant markup parser is used for validation (see the Validator
FAQ).
BTW: This has been discussed ad nauseam before. Read the cljs FAQ.
PointedEars