javascript - Facebook 未捕获的安全错误

标签 javascript facebook

我目前正在寻找制作 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 应用程序页面,但我仍然遇到同样的错误。 enter image description here

这是我使用的代码:

<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>

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

最佳答案

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

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

关于javascript - Facebook 未捕获的安全错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22361362/

相关文章:

javascript - $(selector).val() 不起作用

javascript - react-scripts build thenserve 正在提供 html,而不是 main.js 文件

javascript - 为什么这个简单的 JavaScript 代码无法运行?

java - Codenameone 通过模拟器分享 Facebook

asp.net - 如何在 ASP.NET 中注销 Facebook 连接?

php - 在本地开发 Facebook Canvas 应用程序 -(MAMP、Codeigniter)

facebook - 从Twitter状态获取意图的工具?

javascript - 如何使用 Javascript 动态更改工具提示的文本?

javascript - 无法从 fetch PUT 访问 Express 服务器的正文数据

php - 此应用程序禁止向其他用户发布提要故事