[thelist] dynamically creating comments with JavaScript & document.write
Thomas K. Selig
thomas.selig at gmx.net
Sun Feb 24 09:35:01 CST 2002
Hey,
I currently have a problem trying to dynamically create a comment
using JavaScript's document.write. The idea is to have some lines
commented out if a certain if-clause is true.
The following lines may give a short example of what I'm talking about:
<script language=JavaScript type="text/javascript">
<!--
Browser = Aktiv();
if(Browser) {
document.write("<!--");
}
//-->
</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">
<!--
Browser = Aktiv();
if(Browser) {
document.write("-->");
}
//-->
</script>
I believed that it should work like this, the browsers I tested upon
even strip the code that is supposed to be stripped but even display
"); } //--> instead of the commented text. Obviously, document.write
does not understand what exactly to write (or where to stop reading
the argument).
Any help would be highly appreciated.
/Thomas
--
More information about the thelist
mailing list