Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
444 views
in Technique[技术] by (71.8m points)

javascript - window.opener is undefined on Internet Explorer

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?

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

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I had the same problem and it was due to Internet Explorer Security Options, in particular because my popup was going to an External website (Internet area) and the parent was an internal page (Intranet area). The "Protected Mode" was only activated for the "Internet". I activated it for the "Local intranet" and now it works.

To find this option in IE:

  • Go to Internet Options
  • Security tab
  • Click on "Internet" or "Local intranet" icon
  • Check or uncheck the option "Enable Protected Mode"
  • Restart IE

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...