2015-09-17 288 views
1

我遇到了Safari问题,特别是没有从父窗口找到window.opener函数。我打电话的功能在Chrome和Firefox中运行良好。有没有人有任何提示?具有自定义功能的window.opener在Safari中不起作用

窗口1(父)

打开窗口2具有以下:

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

窗口2(弹出)

请求URL页面返回后,以下被叫:

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

我得到以下错误的第一行:

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

注:我试过window.opener,parent.window.opener和window.parent.opener的一些变化。

窗口1(父)回调

是打开的弹出具有以下的JS函数,但它从来没有得到这一点原来的父窗口。

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

回答

1

编辑:请把它当作评论。

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

在eval()的调用中,使参数字符串中的函数成为窗口的属性。如果回调函数使用eval()定义,则可能是问题

+0

太棒了! window.callBackIntegrationCompleted = callBackIntegrationCompleted;正是我所需要的。 – CaptCheech

相关问题