最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

html - does javascript code need to start with "<!-- "? - Stack Overflow

programmeradmin5浏览0评论

I am newbie.

many of javascript code start with <!--

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

and finish with //-->

//-->
    </script>

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

even I cannot find anything with google.

I am newbie.

many of javascript code start with <!--

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

and finish with //-->

//-->
    </script>

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

even I cannot find anything with google.

Share Improve this question edited Jun 4, 2010 at 4:04 Jon Seigel 12.4k8 gold badges60 silver badges93 bronze badges asked Mar 17, 2010 at 10:14 Sungguk LimSungguk Lim 6,2287 gold badges45 silver badges64 bronze badges 1
  • Sorry about my horrible English. – Sungguk Lim Commented Mar 17, 2010 at 10:15
Add a ment  | 

3 Answers 3

Reset to default 15

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

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.

No, Javascript can run perfectly fine without them.

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 :)

发布评论

评论列表(0)

  1. 暂无评论