问题描述
如果我有这样的事情:
<div id="parent">
<iframe....></iframe>
</div>
我可以:window.parent.document.getElementById('parent')。innerHTML。但我有这样的事情:
I could: window.parent.document.getElementById('parent').innerHTML. But I have something like this:
<div>
<iframe....></iframe>
</div>
无论如何访问它?我可能在给定页面上最多有20个iframe,并且不希望制作20个单独的iframe页面。
Is there anyway of accessing this? I might have anywhere up to 20 iframes on a given page, and would prefer not to make 20 individual iframe pages.
谢谢,
Jason
Thanks,Jason
推荐答案
window.frameElement
是对包含当前页面的IFRAME元素的引用。您可以使用 window.frameElement.parentNode
(在IFRAME内)获取未命名的父元素。
window.frameElement
is a reference to the IFRAME element containing the current page. You can use window.frameElement.parentNode
(inside of the IFRAME) to get the unnamed parent element.
Be意识到该物业是非标准的。在Firefox,Opera和IE中支持 frameElement
。
Be aware that the property is non-standard. frameElement
seems to be supported in Firefox, Opera, and IE.
这篇关于访问iframe的“未命名”亲的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!