Validating JavaScript String

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I find myself unable to validate a page with JavaScript. The strings have
actual mark-up.

I isolated the problematic part and put it in the following address:

Is there a way of achieving this functionality and still get it to validate?

Thanks for any help,


Re: Validating JavaScript String

Roy Schestowitz wrote:
Quoted text here. Click to load it

In all closing tags within the script (e.g., document.write('</P>')),
precede the slash with a backslash to "escape" it, like
document.write('<\/P>').  Otherwise, the closing tags are considered
under SGML rules to terminate the script element.

There's a lot of mistaken belief out there about what's needed to make
closing tags within scripts valid; you see a lot of stuff like
document.write('</scri'+'pt>'), perpretrated by people with a vague
idea that they need to do something special to prevent the tag from
being treated as regular HTML, but don't know the actual syntax
requirements which require escaping the slash.  Once some influential
designer does it, everybody else seems to slavishly imitate them, in
cargo-cult fashion.


Re: Validating JavaScript String

Dan wrote:

Quoted text here. Click to load it


Thank you very much. This made my day.


Site Timeline