我记得几年前读过一些相关内容,但我现在不记得了。
这是否与 IE 并将其解析为纯文本有关...?
最佳答案
我认为你的意思是CDATA
This fixes the validator. The problem is that some older web browsers don't understand the CDATA tag and so this breaks your Javascript in those web browsers. Fortunately, Javascript multi-line comments start and finish with characters that do not cause validation errors. We can therefore comment out the CDATA tag in so far as the Javascript processors within the web browsers are concerned while still leaving the Javascript content defined as CDATA as far as the validator is concerned. We do it like this:
<script type="text/javascript">
/* <![CDATA[ */
// content of your Javascript goes here
/* ]]> */
</script>
关于javascript - 为什么人们在他们的 javascript 代码周围添加 <!--//...//--> ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10988791/