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..