Window.opener null on same domain in IE

帅比萌擦擦* 提交于 2019-12-08 07:09:09

问题


I've researched this extensively (there are many similar questions) but I'm not finding the exact answer I'm looking for.

I am creating a single sign-on widget, so the user flow is as follows:

User clicks Login to open window (domain1) > Login flow (domain2) > Landing page (domain1)

Here is the code I'm using on the landing page:

<html>
<head>
    <title>Redirect</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <script type="text/javascript">
    if (window.opener && !window.opener.closed) {
        setTimeout(function(){
            window.opener.location.href = "[some URL]";
            window.close();
        },2000);
    }
    </script>
</head>
<body>
    <p>Logging you in...</p>
</body>
</html>

The purpose of having the landing page at the end is so that I can eliminate cross-domain issues with accessing window.opener.

This works like a charm in all browsers except IE (gasp!). IE says window.opener is null, even though I have returned to my own domain.

Nothing I've read so far really solves this issue. I have to think there must be some way to do this, since so many sites are using FSSO. Unfortunately, it's not an option for us to find an alternative to a popup window.

Is this just impossible to do in IE due to browser-related security? The only other thing I can think of is to put some kind of listener on the parent to wait for the child to close. Ugh.


回答1:


It seems the issue was related the security zones set on our corporate IE builds. The different domains were relegated to separate zones. Apparently IE loses the value of window.opener when passing through these zones and doesn't bother to reset it. When tested on an outside build of IE it worked.



来源:https://stackoverflow.com/questions/15822885/window-opener-null-on-same-domain-in-ie

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!