HTML comments within JavaScript - Netscape documentation ??

G

Griff

Hi there

About this business of embedding HTML comments in Javascript.

Everyone tells me that JavaScript parsing ignores any line starting
with <!--
but that I need to protect any occurrence of --> with a Javascript
comment //.

My browser (IE 6) seems to handle <!-- as described, but also seems
to ignore occurrences of -->, with or without a leading //.

I was trying to look up the official ruling on this in the
JavaScript 1.5 Guide and Reference on Netscape, but I can't seem to
find any mention of it in the various Netscape documents. So is this
an undocumented convention which JavaScript compliant browsers can
choose to handle just as they like ?

thanks

- griff
 
L

Lasse Reichstein Nielsen

Richard Cornford said:
The browsers that were new when it was introduced are now the oldest
still in use.

They are not even close to being in use. The script tag, and the HTML
comment convetion, was introduced with the transition from Netscape 1
to Netscape 2. The release of Netscape 2.0 was March 1996. Netscape 2
works fine without the HTML comments.

IE supported scripts from v3.0(beta1) in May 1996.

The script tag was then introduced into HTML 3.2, which was made a
recommendation in 1997.

/L
 
R

Richard Cornford

Lasse Reichstein Nielsen said:
They are not even close to being in use. ...
... . The release of Netscape 2.0 was March 1996. ...
<snip>

Yep you are right. I will have to switch to saying "The browsers that
were new when it was introduced are not even still in use.".

(Though I did recently discover that Sheffield university is still
running some machines with Window 3.1 installed, but I doubt that anyone
does much web browsing from them.)

Richard.
 
J

Jim Ley

But
there is no evidence that any of the browsers that are currently in use
do not know how to handle SCRIPT tags properly, so there is no reason
for using this "hide from older browsers" stuff at all. The browsers
that were new when it was introduced are now the oldest still in use.

Also if you're the sort of person who follows such cargo-cults, you
may be the sort of person to jump on the XHTML bandwagon, and for
XHTML the browser is free to chuck away everything inside a comment,
so your script could simply disappear.

Jim.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top