When is a CDATA section necessary within a script tag?

来源:互联网 发布:网络剧招商方案 编辑:程序博客网 时间:2024/05/22 05:16
转载自:http://stackoverflow.com/questions/66837/when-is-a-cdata-section-necessary-within-a-script-tag

When browsers treat the markup as XML:

<script><![CDATA[    ...code...]]></script>

When browsers treat the markup as HTML:

<script>    ...code...</script>

When browsers treat the markup as HTML and you want your XHTML 1.0 markup (for example) to validate.

<script>//<![CDATA[    ...code...//]]></script>
0 0
原创粉丝点击