Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

window.opener with a custom function does not work in Safari

I am having an issue with Safari, specifically, not finding the window.opener function from the parent window. The function I'm calling works fine in Chrome and Firefox. Does anyone have any tips?

Window 1 (Parent)

Opens window 2 with the following:

window.open(requestUrl, "_blank", "width=440, height=500, scrollbars");

Window 2 (Popup)

After the request url page returns back, the following gets called:

window.parent.opener.callBackIntegrationCompleted("testing");
window.close();

I get the following error on the first line:

TypeError: undefined is not a function (evaluating 'window.parent.opener.callBackIntegrationCompleted("testing")')

Note: I've tried a few variations of window.opener, parent.window.opener, and window.parent.opener.

Window 1 (Parent) Callback

The original parent window that opened the popup has the following JS function, but it never gets to this point.

function callBackIntegrationCompleted(code) {
    console.log("got here");
}
like image 288
CaptCheech Avatar asked Dec 06 '25 06:12

CaptCheech


1 Answers

Edit: please treat this as comment.

function callBackIntegrationCompleted(code) {
    console.log("got here");
}
window.callBackIntegrationCompleted = callBackIntegrationCompleted;

inside a call to eval() makes a function in the argument string a property of the window. If the call back function is defined using eval() it could be a problem

like image 61
traktor Avatar answered Dec 08 '25 19:12

traktor



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!