Why? //<![CDATA[

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
 
B

bruce barker

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top