【问题标题】:Facebook Uncaught SecurityErrorFacebook 未捕获的安全错误
【发布时间】:2017-09-14 02:48:42
【问题描述】:

我目前正在寻找制作 Facebook JavaScript 应用程序。因此,我实际上只是将文档中的粘贴内容复制到我的页面中,并且在控制台中不断收到以下错误:

Uncaught SecurityError: Blocked a frame with origin "http://static.ak.facebook.com" from accessing a frame with origin "http://localhost:8080". Protocols, domains, and ports must match. VM2813:1
Uncaught SecurityError: Blocked a frame with origin "https://s-static.ak.facebook.com" from accessing a frame with origin "http://localhost:8080".  The frame requesting access has a protocol of "https", the frame being accessed has a protocol of "http". Protocols must match.
 VM2817:1
Uncaught SecurityError: Blocked a frame with origin "http://static.ak.facebook.com" from accessing a frame with origin "http://localhost:8080". Protocols, domains, and ports must match. 

因此,我随后希望将 http://localhost:8080 添加到我的 Facebook 应用页面,但我仍然遇到同样的错误。

这是我正在使用的代码:

<body>

    <div id="fb-root"></div>
    <script>
      window.fbAsyncInit = function() {
        FB.init({
          appId      : '644205045632878',
          status     : true,
          xfbml      : true
        });
      };

      (function(d, s, id){
         var js, fjs = d.getElementsByTagName(s)[0];
         if (d.getElementById(id)) {return;}
         js = d.createElement(s); js.id = id;
         js.src = "//connect.facebook.net/en_US/all.js";
         fjs.parentNode.insertBefore(js, fjs);
       }(document, 'script', 'facebook-jssdk'));
    </script>
</body>

请有人解释一下这里出了什么问题。这是我第一次这样做...

【问题讨论】:

  • 我猜您在用户设置中启用了“安全浏览”,因此您的服务器也需要能够通过 HTTPS 进行响应...

标签: javascript facebook


【解决方案1】:

如果您在看到这些错误消息时使用 安装了 Ripple 模拟器的 Chrome 进行测试,请尝试禁用 Ripple(从设置中,而不仅仅是针对特定页面)。显然,即使没有为特定页面启用 Ripple,它也会拦截响应并阻碍。

我在安装并启用了 Ripple Emulator (Beta) 0.9.15 扩展程序的 Windows 7 Pro 64 位上的 Chrome 版本 34.0.1847.131 中观察到了这一点。

【讨论】:

  • 谢谢!当我摆脱它时,错误就消失了。无论如何,它对我没有任何用处。
  • 在 linux 版本 47.0.2526.73(64 位)上相同。我什至没有意识到它已安装,我怀疑它带有“Web Developer”工具,无论是安装还是 chrome 安装并默认启用它
【解决方案2】:

正如@peterr 指出的,您必须仅从Extensions (http://chrome://extensions/) 禁用Ripple

从这里禁用它不起作用

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-07-11
    • 2016-03-19
    • 2021-04-19
    • 2016-02-27
    • 1970-01-01
    • 2014-12-07
    • 1970-01-01
    相关资源
    最近更新 更多