Facebook与网站集成 - 协议错误[http / https]

时间:2015-12-26 18:48:59

标签: facebook facebook-javascript-sdk facebook-like

我决定将FB登录/共享功能集成到我的网站。但是,我无法使简单的脚本工作,因为我得到http // https协议错误:

Uncaught SecurityError: Blocked a frame with origin "https://staticxx.facebook.com" from accessing a frame with origin "http://www.my-site.com".  The frame requesting access has a protocol of "https", the frame being accessed has a protocol of "http". Protocols must match.

我从FB docs复制粘贴的代码是:

<div id="fb-root"></div>
<script>(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/sdk.js#xfbml=1&version=v2.5&appId=505598882820893";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

<div class="fb-like" data-href="https://developers.facebook.com/docs/plugins/" data-layout="standard" data-action="like" data-show-faces="true" data-share="true"></div>

实际上,当我运行登录script时,我遇到了同样的错误。

我查看了答案herehere,但它们在我的案例中没有用。

1 个答案:

答案 0 :(得分:5)

知道了。感谢另外一个问题:Facebook Uncaught SecurityError

从Chrome扩展程序禁用'RIPPLE EMULATOR'。