</SCRIPT> (Pitfall)

Problems with closing <SCRIPT> tags.

You cannot use the string '</SCRIPT>' within an inline JavaScript fragment. Even if it is enclosed inside quotation marks, it will still be seen by the parser and interpreted as a closure to the <SCRIPT> tag. You will need to hide it by constructing the string from component parts and using concatenation techniques to manufacture the string you need.

If you need to say this:

var myScriptTag = '</SCRIPT>';

Then you should do this:

var myScriptTag = '<' + '/SCRIPT' + '>';

which should hide the tag from the parser.

Another alternative is to escape the slash character with a backslash like this:

var myScriptTag = '<\/SCRIPT>';

Look at that previous line carefully, and see how the forward slash is preceeded by a backslash. After a long day cranking code out that might look like an upper case V, so it might be best to use the concatenation technique.

See also:<SCRIPT>, Pitfalls

Cross-references:

Wrox Instant JavaScript - page 45