简体   繁体   English

如何从Internet Explorer获取在JavaScript中打开窗口的iframe?

[英]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.

相关问题 如何在Internet Explorer 8中获取innerWidth - How Do I Get innerWidth in Internet explorer 8 VBA / Internet Explorer / Javascript:如何从同一Internet Explorer打开JavaScript窗口? - VBA / Internet Explorer / Javascript: How to open a javascript window from same internet explorer? 你如何获得window.open在Internet Explorer 7中工作? - How do you get window.open to work in internet explorer 7? 我需要什么才能在Internet Explorer中使用JavaScript? - What do i need to get javascript working in Internet Explorer? 如何让JavaScript生成的图像映射与Internet Explorer一起使用? - How do I get JavaScript-generated image maps to work with Internet Explorer? 如何在Internet Explorer的网页上从javascript调用.Net控件或类库? - How do I call a .Net control or class library from javascript on a web page in Internet Explorer? 我如何获得提示(例如cluetip)以在Internet Explorer中工作? - how do i get a tooltip such as cluetip, to work in Internet Explorer? 如何从Internet Explorer 9创建弹出窗口 - How To Create a Popup Window from Internet Explorer 9 如何从Internet Explorer中的剪贴板获取base64编码图像? - How do i get base64 encoded image from clipboard in internet explorer? 使用Java加载后打开的窗口如何关闭? - How do I close a window I opened after it loads with Javascript?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM