将脚本标记放在正文的结束标记(</body>
)之后有多大错误?
<html>
....
<body>
....
</body>
<script type="text/javascript" src="theJs.js"></script>
</html>
发布于 2010-06-14 21:53:09
发布于 2012-02-15 22:21:45
作为Andy said,文档将无效,但脚本仍将被解释。有关示例,请参阅WebKit的the snippet:
void HTMLParser::processCloseTag(Token* t)
{
// Support for really broken HTML.
// we never close the body tag, since some stupid web pages close it before
// the actual end of the doc.
// let's rely on the end() call to close things.
if (t->tagName == htmlTag || t->tagName == bodyTag
|| t->tagName == commentAtom)
return;
...
发布于 2013-07-25 06:21:00
I浏览器不再允许这样做(我相信是从version 10开始),并且会忽略这样的脚本。
Firefox和Chrome仍然容忍它们,但有可能有一天他们会因为非标准而放弃它。
https://stackoverflow.com/questions/3037725
复制相似问题