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 :
- Why there are commented out CDATA tags around my script include? Do these even do anything?
- Why it's using a
document.write
inside of the script tag to include... another script tag?
- 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.
- 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.
精彩评论