我正在尝试将我的文档验证为 XHTML 1.0 Transitional (W3C)。
我有以下错误: “文档类型不允许此处使用元素“noscript”;假设缺少“对象”开始标记” 对应于这段代码:
<noscript>
<div style="display:inline;">
<img height="1" width="1" style="border-style:none;" alt=""
src="//googleads.g.doubleclick.net/pagead/viewthroughconversion/1096/?
value=1.00&label=Y-skCMY_QM&guid=ON&script=0"/>
</div>
</noscript>
</head>
但是我的验证失败了。问题是什么?请帮我解决这个问题。
最佳答案
您的解决方案之一可能是将其放在 body
中而不是 head
您的文档如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Title</title>
<meta name="viewport" content="width=device-width"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<noscript>
<div style="display:inline;">
<img height="1" width="1" style="border-style:none;" alt=""
src="//googleads.g.doubleclick.net/pagead/viewthroughconversion/1096/?
value=1.00&label=Y-skCMY_QM&guid=ON&script=0"/>
</div>
</noscript>
</body>
</html>
这会导致:
This document was successfully checked as XHTML 1.0 Transitional!
此外,根据this answer ,这似乎并没有真正的区别(我在这里谈论 head
与 body
):
Have done the move with the Google Ad section outside of HEAD and just in the BODY part itself. Really doesn't make a difference since when it was moved, it was just right after the parameters used for the ads to display.
解决方案#2
如果您需要删除 <noscript>
无论如何,您可以尝试进行以下操作:
<div id='noscript' style="display:inline;">
<img height="1" width="1" style="border-style:none;" alt=""
src="//googleads.g.doubleclick.net/pagead/viewthroughconversion/1096/?
value=1.00&label=Y-skCMY_QM&guid=ON&script=0"/>
</div>
<script>document.getElementById('noscript').style.display='none'</script>
这使得事情的工作方式与第一个解决方案完全相同。如果 JavaScript 被禁用,<script>...</script>
不会被执行,因此 <div>...</div>
将显示。
关于xhtml - 错误 "noscript",W3C XHTML,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28241669/