检查文档是否为ROOT节点 [英] Check if document is ROOT node
本文介绍了检查文档是否为ROOT节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要知道文档元素是否是页面的ROOT节点。例如:
I need to know if the document element is the ROOT node of the page. For example:
<html> <-- ROOT Node
<head></head>
<body>
<iframe>
<html>...</html> <-- other document
</iframe>
<iframe>
<html>...</html> <-- other document
</iframe>
</body>
</html>
在iframe 1或2中执行的Javascript应该知道他们的文档节点是否是根节点。
Javascript that is executed in iframe 1 or 2 should know if their document node is the root node.
希望你能帮助我。
推荐答案
你应该能够使用 top
执行此操作:
You should be able to do this with top
:
if (window.top.document === window.document) {
// we're in the outermost window
}
这篇关于检查文档是否为ROOT节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文