3

I am using window.postMessage for cross domain popup communication. Everything seems to be working fine on firefox and chrome. The main problem is with IE11. I tested on multiple systems IE11,for few systems its working fine, but for other systems it does not seems listen the message on the parent page.

As we all(who tested) are under a same network, we have the same version of IE. The exact version: 11.0.9600.18314CO. Its very frustrating since last 2 days.

Update:

I am seeing the document mode is different in the different browser. On my browser the website loads with EDGE and everything working fine. In some other system its loading with IE7 mode and that is causing the issue.

Now i am not sure why for the same website the document mode is different on different system IE.

Here is an example: http://plnkr.co/edit/pK4XBJDrqFrE7awvMlZj?p=preview

Page 1: 
<!DOCTYPE html>
<html>
<head>
  <script>
    var popup = window.open("popup.html", "popup", "width=200,height=200");
    function receiveMessage(event) {
      if (event.origin === "http://run.plnkr.co") {
        console.log(event, event.data);
        this.location.href = event.data;
      }
    }
    window.addEventListener("message", receiveMessage, false);
  </script>
</head>
<body>
</body>
</html>

Page 2:
<!DOCTYPE html>
<html>
<head>
</head>
<body>
  <form>
    <input type="button" value="Save">
  </form>
    <script>
    console.log(window.opener);
    var button = document.querySelector("form input[type=button]");
    button.onclick = function(e) {
      e.preventDefault();
      e.stopPropagation();
      window.opener.postMessage("redirect.html"
                    , window.opener.location.href);
      window.close();
    }
    </script>
</body>
</html>

Page 3:

<!doctype html>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
<meta charset='utf-8' />
<style type='text/css'></style>


</head>
<body>
redirected
</body>
</html>

Any help would be appreciated..

user3714162
  • 89
  • 2
  • 7
  • Possible duplicate of [**Is cross-origin postMessage broken in IE10?**](http://stackoverflow.com/questions/16226924/is-cross-origin-postmessage-broken-in-ie10) and see this -> **http://caniuse.com/#search=postMessage** – davidkonrad Jun 21 '16 at 04:22
  • @davidkonrad: Please check my update on the question. let me know if you have any idea on that. – user3714162 Jun 21 '16 at 04:28
  • "_I am seeing the document mode is different in the different browser_" seems to me you need to force the various MS browsers into a single standardized mode, i.e [``](http://stackoverflow.com/q/5374099/1407478) or similar. – davidkonrad Jun 21 '16 at 04:33
  • Did you manage to fix this issue? I'm having the same problem though. – John Roca Jul 28 '17 at 06:24

1 Answers1

1

I had same conditions - cross domain popup window dialog and very similar code, which also did not work in IE11 (older versions not relevant for me). In my case I found out it does not work because of Internet Explorer security zones.

My opener page was among Trusted sites, the dialog page was not. Found out it works if both sites have the same zone (either trusted or internet).

From my tests it seems to me, that your code does not work because of window.opener.location.href. Probably you cannot access window opener properties. If I changed it to particular domain, it started to work.

mivra
  • 1,310
  • 16
  • 30