开发者

What does it mean when your javascript is rendered like this?

I was looking at the page source for an ASP.NET page I wrote and noticed that my javascript was being rendered like this:

<script type="text/javascript">
   // <![CDATA[
   document.write('<script src="/_layouts/myProject/js/开发者_如何学编程jquery.min.js?rev=sEo7zNI93reYIUNwemPM%2BQ%3D%3D"></' + 'script>');
   // ]]>
</script>

Does anyone know :

  1. Why there are commented out CDATA tags around my script include? Do these even do anything?
  2. Why it's using a document.write inside of the script tag to include... another script tag?


  1. Because text nodes in XML that may contain HTML (but shouldn't be parsed as such) should be in CDATA blocks. Because the block definition is not valid JavaScript, it is commented out.
  2. I'm not sure why. I don't think they are downloaded any differently (I imagine a JavaScript disabled browser won't ever download JavaScript files anyway).


Basically the commented CDATA tag is for browsers which doesn't support javascript and for the second one its inserting another javascript file to the page.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜