-2

I want to listen click/submit event from popup window to parent page. Here below code works if both parent and popup window belongs to same domain say http://localhost (check below commented line in code) but it will not call eventHandler method if popup has different domain say echosign.com. In below code parent window is localhost or anything other than popup.

var newWindow;
function OpenPopup() {
    //newWindow = window.open("http://localhost:21930/Popup.htm", "PopupWindow", "width=300,height=100");
    newWindow = window.open("https://secure.echosign.com", "PopupWindow", "width=300,height=100");
    if (newWindow.addEventListener) {
        newWindow.addEventListener('click', eventHandler, false);
    } else {          
        newWindow.attachEvent('onclick', eventHandler);
    }
}

function eventHandler(e) {
    if (e.currentTarget.origin == "https://secure.echosign.com") {
        console.log("Event from Adobe Sign!", JSON.parse(e.data));           
    } else {
        console.log(e.currentTarget.origin);           
    }
}
ADP
  • 123
  • 1
  • 2
  • 11

1 Answers1

0

If you have control on both domains you can set the headers to accept the other domain.

Access-Control-Allow-Origin: http://localhost
MNOor
  • 36
  • 1
  • 4
  • Thanks for reply: I don't have any control on popup window domain. but as security wise we allowed this domain to our project. – ADP Nov 11 '17 at 13:01