[thelist] dynamically creating comments with JavaScript & document.write

Peter-Paul Koch gassinaumasis at hotmail.com
Sun Feb 24 11:33:01 CST 2002


><script language=JavaScript type="text/javascript">
><!--
>	Browser = Aktiv();
>	if(Browser) {
>		document.write("<!--");

The HTML parser of the browser may find the start a new tag here: start of
an HTML comment that comments out the /script and the content.
This won't happen in all browsers but it might happen in some.

>	}
>//-->
></script>
>
>.....Code that is supposed to be commented away
>.....Code that is supposed to be commented away
>.....Code that is supposed to be commented away
>
><script language=JavaScript type="text/javascript">
><!--

Here the HTML parser finds a start of a comment.

>	Browser = Aktiv();
>	if(Browser) {
>		document.write("-->");

Here any HTML parser of any browser is certain that either the comment or
the script tag (or both) has ended and it should normally display the
following text: "); } //-->

>	}
>//-->
></script>

>Any help would be highly appreciated.

Not sure this can be done at all in JavaScript. Obviously you could try to
write &lt; and &gt; instead of the < and > but if any browser made it a
start and end of a tag I'd be highly surprised.

ppk

_________________________________________________________________
MSN Photos is the easiest way to share and print your photos:
http://photos.msn.com/support/worldwide.aspx




More information about the thelist mailing list