[英]How do I get the iframe that opened a window in JavaScript from Internet Explorer?
I have an iframe that opens a new webpage. 我有一个iframe,可以打开一个新网页。
In that webpage, I want to access a function on the window of the iframe. 在该网页中,我想访问iframe窗口上的功能。
I try to call window.opener.myFunction()
, but the opener is the <iframe>
's parent window, and not the <iframe>
's window. 我尝试调用window.opener.myFunction()
,但是打开器是<iframe>
的父窗口,而不是<iframe>
的窗口。
Because of the dynamic nature of the page, I don't want to explicitly get the contentWindow of the <iframe>
from the parent window. 由于页面的动态性质,我不想从父窗口中显式获取<iframe>
的contentWindow。 Does anyone know of a workaround? 有人知道解决方法吗?
If you know the <iframe>
's id, you could use getElementById(). 如果知道<iframe>
的ID,则可以使用getElementById()。
For example: 例如:
The first webpage would have: 第一个网页将具有:
<iframe id="launcher"></iframe>
And the launched page could use: 启动的页面可以使用:
window.opener.getElementById("launcher").myFunction();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.