问题
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");
}
回答1:
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
来源:https://stackoverflow.com/questions/32639654/window-opener-with-a-custom-function-does-not-work-in-safari