Why are javascripts sometimes surrounded by these tags?
Why are some JavaScripts encapsulated within these tags:
<!--//--><![CDATA[//>开发者_运维问答<!--
some js here
//--><!]]>
<![CDATA[//> is to prevent XML parsers from choking on the script.
<!-- ... --> is not required unless you're using Netscape 1.0.
See: Does it still make sense to use HTML comments on blocks of JavaScript?
It makes it valid XHTML.
They were used for old browsers which didn't understand the <script> tag. That way if a browser didn't properly read the JavaScript, it would just render it as a comment and not show up on the page.
It also allows JavaScript code to be inside valid XHTML pages without having to escape characters which aren't valid in XML.
加载中,请稍侯......
精彩评论