Facebook Uncaught SecurityError

时间:2014-03-12 19:02:23

标签: 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>

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

2 个答案:

答案 0 :(得分:60)

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

我在Windows 7 Pro 64位上使用Chrome版本34.0.1847.131观察到此情况,并安装并启用了Ripple Emulator(Beta)0.9.15扩展程序。

答案 1 :(得分:0)

正如@peterr指出的那样,您必须仅从Extensionshttp://chrome://extensions/)禁用 Ripple enter image description here

从此处停用将无效

enter image description here