在Internet Explorer上未定义window.opener [英] window.opener is undefined on Internet Explorer

查看:226
本文介绍了在Internet Explorer上未定义window.opener的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试从弹出窗口访问父窗口的元素时,我得到 window.opener 为未定义。

When I am trying to access an element of my Parent window from a Pop-up window, I am getting window.opener as undefined.

var opener = window.opener;
if(opener) 
{
    console.log("opener element found");
    var elem = opener.$('.my-parent-element');
    if (elem) {
        console.log("parent element found");
        elem.show(); 
    }
}

这里开启者未定义。难道我做错了什么?

Here opener is undefined. Am I doing something wrong?

我试过 parent.window.opener / window.top / window.top.document.body 等,但它也没有帮助。它在其他浏览器中运行良好。

I have tried parent.window.opener / window.top / window.top.document.bodyetc., but it doesn't help either. It works fine in other browsers.

我看到了问题 Window Opener Alternative ,但我无法立即更改 showModalDialog 打开我的弹出式窗口。可能,这将是最后一个选项。

I have see the question Window Opener Alternative, but I cannot change opening my popup with showModalDialog right away. Probably, this would be last option.

推荐答案

您可以使用 showModalDialog 如果使用的浏览器是IE,则函数和传递参数。只需将 window 对象作为参数传递即可。

You can use the showModalDialog function and pass arguments to it, if the browser used is IE. Simply pass window object as an argument.

之后你可以使用 dialogArguments 从模态窗口访问参数。

After that you can access the arguments from the modal window using dialogArguments.

更多细节可以在这里的文档中找到: http://msdn.microsoft.com/en-us/library/ms533723%28VS.85%29.aspx

More details can be found in the documentation here: http://msdn.microsoft.com/en-us/library/ms533723%28VS.85%29.aspx

示例检索:

window.showModalDialog(theURL, window);

//in the modal dialog you can use this to retrieve the window.
var openerWindow = window.dialogArguments;

这篇关于在Internet Explorer上未定义window.opener的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆