Cross Origin窗口控件

时间:2014-06-05 08:58:17

标签: javascript oauth

我正在尝试通过我的网络应用程序构建Google Plus登录,就像你在foursquare.com上通过oauth popup看到的一样。应用程序在控制台中显示以下错误。

  

Uncaught SecurityError:阻止了一个包含起源的框架" http://airus.com:3000"从访问带有起源的框架" https://accounts.google.com"。请求访问的帧具有" http"的协议,被访问的帧具有" https"的协议。协议必须匹配。

<script type="text/javascript">
    var REDIRECT    =   'http://airus.com/users/auth/google_oauth2/callback';
    function login(url, x) {
        var win         =   window.open(url, "windowname1", 'width=400, height=600'); 
        var pollTimer   =   window.setInterval(function() { 
            console.log(win.document.URL);
            if (win.document.URL.indexOf(REDIRECT) != -1) {
                window.clearInterval(pollTimer);
                var url =   win.document.URL;
                win.close();
                x.reload();
            }
        }, 500);
    }
    $("#link").click(function(){
        x = location;
        login($(this).attr('href'), x);
        return false;
    })
</script>

知道如何解决?

1 个答案:

答案 0 :(得分:0)

错误信息实际上是在点上:

  

请求访问的帧具有&#34; http&#34;的协议,被访问的帧具有&#34; https&#34;的协议。协议必须匹配。

因此,您必须通过https(SSL,端口443)为您的网站提供服务。这样您网页的网址就会变为https://airus.com(:443)

相关问题