1

I am trying to write a callback in my app that opens a popup, does some stuff and responds to the popup opener window to mark the action as complete.

The popup uses window.opener.postmessage() method to communicate with the opener window in browser.

Its working in most browsers. However, Internet Explorer 11.0.x is not able to postmessage, whereas 11.192.x is able to. I have not checked with IE,9/10.

The error is Permission Denied and window.opener is undefined Is there any way to resolve this and make my popup send message to opener window in Internet Explorer 11.0.x?

Thanks.

1 Answers1

0

I haven't tried this on Internet Explorer, but let me know if it works for you.

Create an empty object to hold your data on the window object.

eg.

window._myData = {};

Create a function on the window object. The function is what does the stuff you want to do, sets the data and gets called when the new window closes.

eg.

window._popupClosing = function(data){ this._myData = data; console.log('done....', this._myData); };

Open your popup window.

eg.

var w = window.open('https://google.com','_blank');

Set a timer to check if the window has been closed. Then run your function.

eg.

var timer = setInterval(function(){ if(w.closed){ clearInterval(timer); window.parent._popupClosing(window.location.href); } }, 1000);

Remember to close the new popup from a script within the popup using

window.close();

Combining these

window._myData = {}; window._popupClosing = function(data){ this._myData = data; console.log('done....', this._myData); }; var w = window.open('https://google.com','_blank'); var timer = setInterval(function(){ if(w.closed){ clearInterval(timer); window.parent._popupClosing(window.location.href); } }, 1000);

Remember to close the new popup when you are done. window.close();

If you can post your data to an endpoint then retrieve the data from the endpoint in your popup close function, that will be better than sending data between windows. I think.