是否可以有在<脚本>里面?脚本>
HTML 页面中的 script> 标记内是否可以有
定义?
我收到错误消息 A DOCTYPE is not allowed in content 。
有人可以告诉我我是否应该因此而收到任何此类错误吗?
Is it possible to have <DOCTYPE>
definition inside <script>
tag in an HTML page?
I get an error that A DOCTYPE is not allowed in content .
Could someone tell me if I should be getting any such error for that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您的文档类型应该位于文档的顶部。为什么要把它放在其他地方?
Your doctype should be at the top of your document. Why do you want to put it anywhere else?
你这样做的方式(使用
)是相当危险的,但是无论你想完成什么,都可以用 CDATA 来修复:
< ;script type="text/plain">
(您的文档)
]]>
The way you're doing it (with
<script type="text/plain">
) is fairly dangerous, but whatever you want to accomplish there can be fixed with CDATA:<script type="text/plain">
<![CDATA[
(Your document)
]]>
</script>
请记住 doctype 是浏览器指令,而不是实际的 html。因此,将它放在顶部以外的任何地方有点奇怪,但更重要的是它不会做任何事情。
Keep in mind doctype is a browser instruction, not actual html. Therefore having it anywhere but the top is a bit odd, but more importantly it won't do anything.
您的问题迫使我假设您更好地理解文档类型是什么,此链接可能会有所帮助:http: //www.w3.org/QA/Tips/Doctype
Your question forces me to assume that you better understanding of what a doctype is, this link might help: http://www.w3.org/QA/Tips/Doctype