CDATA Everything inside is ignored by the parser, and the added text contains a large number of < and $ symbols, as is often the case in programming, so this element can be defined as a CDATA section, andCDATA sections begin with "<![ Cdata[", End at"]]> ":
Why use this?
XHTML the second change is to use CDATA segments, which areused to declare text that should not be parsed as labels (XHTML is also the case), so that special characters such as less than (<), greater than (>), and Number (&), and double quotation marks (") are used. Instead of having to use their character entities
Here's how to formally add CDATA segments:
<script type= "Text/javascript" ><! [cdata[function Compare (b) {if (a < b) {alert ("A less than B");} Else if (a>B) {Alert ("a greater than B");} Else {alert ("a equals B");}]] ></script>
While this is a formal approach, remember that most browsers do not fully support XHTML, which poses the main problem, which is a syntax error in JavaScript, because most browsers do not yet recognize CDATA segments.
<script type= "Text/javascript" >//<![ cdata[ function Compare (b) {if (a < b) {alert ("A less than B");} Else if (a>B) {Alert ("a greater than B");} Else {alert ("a equals B");}} // ]]> </script>
The solution currently in use mimics the method of hiding code from the old browser. Use a single-line JavaScript comment "//" to embed a CDATA segment without affecting code syntax:
This code can now be run in browsers that do not support XHTML.
However, to avoid CDATA problems, it is best to introduce JavaScript code with external files.
JS in//<! [cdata[meaning