iframe
的JS变量,指向 iframe,那么外部文档将看到 iframe.contentWindow.document.getElementsByTagName('body')[0].ownerDocument === iframe.contentWindow.document
,而不是 iframe.contentWindow.document.getElementsByTagName('body')[0].ownerDocument === window.document
,因为 iframe 有一个不同的 window
对象(外部文档引用为 iframe.contentWindow
)。同样地,在辅助浏览器窗口中也是如此。 - ruakh