javascript - Oauth 登录弹出窗口未在 ie 中关闭

标签 javascript internet-explorer

我已经为 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/

相关文章:

html - 为什么它的 bordercolour 似乎只在 chrome 而不是 internet explore 或 firefox 中运行

html - IE 和 HTML5 文档类型问题

Javascript 多个 setIntervals

javascript - 从字符串中获取一部分

javascript - @babel/register 中忽略的正确正则表达式模式是什么

javascript - 使用 javascript 控制 css 适用于 Mozilla 和 Chrome,但不适用于 IE

javascript - 以 Angular 将服务添加到 Controller

javascript - 如何使用 JavaScript 创建教程步骤

javascript - IE 图像映射在另一个 div 后面仍然可以点击

Internet Explorer 中的 jquery show()/hide() 问题?