我为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但是点击后允许它不进入内部,如果是window.setinterval函数,这就是为什么弹出窗口没有关闭,即在firefox和chrome窗口正在关闭如何解决这个问题。/ p>
答案 0 :(得分:0)
您应该在新窗口中打开登录页面,然后重定向到成功页面,然后关闭弹出窗口:
page.html中
function login() {
var win = window.open('', 'login.html', 'width=800,height=400');
win.focus();
}
的login.html
window.location.href = 'success.html'; // or use server-side redirect
success.html
window.opener.close();