pin*_*yid 7 javascript google-chrome google-oauth
间歇性地我得到一段时间,调用gapi.auth.authorize会导致在我的应用程序窗口下打开一个帐户选择器窗口,当然它会被用户忽视.
有没有办法强迫它在顶部,或至少检测它已被打开所以我可以提醒用户?
我目前正在测试Chrome,但我也在Firefox上看过它.
要重新创造......
它应该(有时是)应该是什么样的......
什么不应该,但有时看起来像......
我无法通过在后台启动弹出窗口来重现您的问题,但我可能为您提供了解决方案。
这是一个 hack,但它避免了直接修改 Google 的代码。
这是重要的部分,下面提供了一个演示。本质上,您window.open
在弹出窗口创建后不久就覆盖并聚焦它。窗口打开后,您将恢复window.open
默认功能。
function handleAuthClick(event) {
// Hijack window.open
var windowOpen = window.open;
window.open = function(url, name, options) {
var newWindow = windowOpen.apply(this, arguments);
setTimeout(function() {
newWindow.focus();
}, 0);
return newWindow;
};
gapi.auth.authorize({client_id: clientId, scope: scopes, immediate: false}, handleAuthResult);
// Release window.open
window.open = windowOpen;
return false;
}
Run Code Online (Sandbox Code Playgroud)
演示:
http: //jsbin.com/sefozinu/1/edit
众所周知,Chrome 和 FireFox 的更高版本不尊重window.focus
.
归档时间: |
|
查看次数: |
538 次 |
最近记录: |