views:

154

answers:

3

I am newbie.

many of javascript code start with <!--

<script type="text/javascript">
        <!--

and finish with //-->

//-->
    </script>

I think the reason is for compatibility.
But I cannot find the clue in any books.

even I cannot find anything with google.

+13  A: 

No. This is a holdover from the days when Netscape 2 was common.

It isn't needed with any browser that can function on the web today, and it is positively harmful in XHTML.

I wrote a longer explanation last year.

David Dorward
thanks, my question is duplicate T.T
sunglim
+1  A: 

No, Javascript can run perfectly fine without them.

JonnyLitt
+1  A: 

The reason was to hide JavaScript from any browser that doesn't know how to handle it. Those browsers used to display the code to the user. Hence, a way to hide code from those browsers was introduced. As there aren't any browsers around that don't know about JavaScript nowadays, it's mainly a remainder from the good ol' days :)

sfussenegger