【问题标题】:Cross Origin window control跨域窗口控制
【发布时间】:2014-06-05 08:58:16
【问题描述】:

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

未捕获的安全错误:阻止了来源为“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>

知道怎么解决吗?

【问题讨论】:

    标签: javascript oauth


    【解决方案1】:

    错误消息实际上是在:

    请求访问的帧的协议是“http”,被访问的帧的协议是“https”。协议必须匹配。

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

    【讨论】:

      猜你喜欢
      • 2012-02-16
      • 1970-01-01
      • 2012-04-05
      • 1970-01-01
      • 2017-02-05
      • 2014-10-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多