Oauth登录窗口在ie中没有关闭

Oauth login popup not closing in ie

本文关键字:ie 登录 窗口 Oauth      更新时间:2023-09-26

我写了javascript代码为oauth登录弹出谷歌oauth代码如下

    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);
}
该窗口中的

正在打开,但在单击allow后,它没有进入该窗口。Setinterval函数,这就是为什么在firefox和chrome浏览器中弹出窗口没有关闭的原因,如何在ie中解决这个问题

您应该在新窗口中打开登录页面,然后重定向到成功页面,然后关闭弹出窗口:

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();