我需要知道文档元素是否是页面的根节点。例如:
<html> <-- ROOT Node
<head></head>
<body>
<iframe>
<html>...</html> <-- other document
</iframe>
<iframe>
<html>...</html> <-- other document
</iframe>
</body>
</html>
在 iframe 1 或 2 中执行的 JavaScript 应该知道它们的文档节点是否是根节点。
希望你能帮我。
你应该能够做到这一点top https://developer.mozilla.org/en/DOM/window.top:
if (window.top.document === window.document) {
// we're in the outermost window
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)