Why? //<![CDATA[

  • Thread starter Thread starter shapper
  • Start date Start date
S

shapper

Hello,

Why when I register some Javascript code to the page I get //<!
[CDATA[ before it?

<script type="text/javascript">
//<![CDATA[
$(document).ready(function(){
This is the first script
This is the second script
});
//]]>
</script>

If I write the script myself in the HTML code or using a literal do i
need it?

Thanks,
Miguel
 
to be xhtml compliant. in xhtml, special characters like "<" and ">"
and more are not allowed unless contained in CDATA. so .net puts the
script code in cdata tag. unfortunately, few browser support cdata tags
in a script block, so the convention is to use javascript comments, to
hide the cdata tags.

-- bruce (sqlwork.com)
 
Back
Top