我目前正在寻找制作 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>
请有人解释这里有什么问题。这是我第一次这样做......
最佳答案
如果您在看到这些错误消息时使用 安装了 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/