【发布时间】:2012-10-17 09:47:40
【问题描述】:
我正在尝试在文档的最顶部插入一段 HTML,看起来像这样:
<html>
<frameset onunload="unload()" onload="loadme()" id="topframeset" frameborder="0" framespacing="0" rows="45,19,10,0,*,22">
(...)
</frameset>
</html>
好的 - 看起来很容易。在 Firebug 中我可以做到:
>>> document.getElementById("topframeset")
<frameset id="topframeset" onunload="unload()" onload="loadme()" frameborder="0" framespacing="0" rows="45,19,10,0,*,22">
所以它觉得很好。
然后:
document.insertBefore(document.createTextNode("<h1>hello</h1>"), document.getElementById("topframeset"))
Error: Node was not found
[Break On This Error]
...ertBefore(document.createTextNode("<h1>hello</h1>"), document.getElementById("to...
发生了什么事?
【问题讨论】:
-
也许这是因为您试图构建无效的 HTML 结构。框架集不能有
h1同级。 w3.org/TR/html4/present/frames.html#h-16.2.1 -
我想可能是这样。那么,除了
标签: javascript html frame