我已经为 google OAuth 的 oauth 登录弹出窗口编写了 javascript 代码 代码如下
function authorize(authorize_url,get_token,get_token_secret)
{
console.log("acToken is "+get_token);
var win = window.open(authorize_url, "windowname2", "width=800, height=600");
var pollTimer = window.setInterval(function() {
try
{
if (win.document.URL.indexOf(oauth_callback) != -1) {
console.log("url inside callback"+win.document.URL)
window.clearInterval(pollTimer);
win.close();
getting_access_token(get_token,get_token_secret);
}
}catch(e)
{
}
},100);
}
在该窗口中打开 oauth,但在单击允许后它不会进入 if 的 window.setinterval 函数,这就是为什么弹出窗口在 ie 中没有关闭,在 firefox 中,chrome 窗口正确关闭如何在 ie 中解决这个问题。
最佳答案
您应该在新窗口中打开登录页面,然后重定向到成功页面,然后关闭弹出窗口:
页面.html
function login() {
var win = window.open('', 'login.html', 'width=800,height=400');
win.focus();
}
登录.html
window.location.href = 'success.html'; // or use server-side redirect
成功.html
window.opener.close();
关于javascript - Oauth 登录弹出窗口未在 ie 中关闭,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15542470/