[英]why does the w3 validator check within the <script> tag and raise errors?
I am trying to validate my page using the W3C validator but it keeps looking within the script tag of the javascript and failing. 我正在尝试使用W3C验证程序来验证我的页面,但它一直在javascript的script标签内查找并失败。 any ideas?
有任何想法吗?
It gets treated as PCDATA since it's XHTML ( XML ). 由于它是XHTML(XML),因此被视为PCDATA。 Mark it as CDATA per When is a CDATA section necessary within a script tag?
在脚本标记中何时需要将CDATA节标记为CDATA ? and you should be ok:
而且你应该没事:
<script type="text/javascript">
//<![CDATA[
...code...
//]]>
</script>
Alternatively you can stop attempting to use XHTML by using HTML 5, or throw the code in an external JS file if it's feasible. 另外,您可以通过使用HTML 5停止尝试使用XHTML,或者在可行的情况下将代码扔到外部JS文件中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.