JavaScript代码是否需要以“<! - "开头?” [英] does javascript code need to start with "<!-- "?
本文介绍了JavaScript代码是否需要以“<! - "开头?”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
许多javascript代码都以<! -
< script type =text / javascript>
<! -
结束于 // - - >
// - >
< / script>
我认为原因在于兼容性。
但是我找不到线索在任何书籍中都是如此。
即使我找不到任何与Google有关的信息。 p>没有。这是Netscape 2普遍存在的原因。
今天任何可以在网络上运行的浏览器都不需要它,它对于XHTML。
我写了更长的解释去年。
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.
解决方案
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.
这篇关于JavaScript代码是否需要以“<! - "开头?”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文