在Android chrome浏览器中,window.opener为null(但在隐身模式中则为空)

时间:2018-07-04 20:53:56

标签: javascript oauth instagram mobile-chrome

我要打开一个新窗口以完成Instagram oauth,如下所示:

var newWindow = window.open(url, 'Instagram Login', 'scrollbars=yes, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left);

其中url只是给定应用程序的oauth路径。通过身份验证后,以下代码将查找在应用程序端定义的函数以触发成功回调:

if (window.opener && window.opener.foo) {
    window.opener.foo("photo:social:login:success", gon.social_profile);
}

这在台式机和ios上都可以正常使用,但是android chrome告诉我window.opener为空,这意味着从未实现回调。

奇怪的是,在android chrome的隐身窗口中尝试完全相同的流程,它可以正常工作。 window.opener指向原始窗口,并且回调函数已成功触发。

我已经尝试使用parent.window.openertop.window.opener,因为打开弹出窗口的代码在iframe内,但似乎没有什么区别。 android有什么理由在这里会有所不同?

0 个答案:

没有答案
相关问题