我正在使用 jQuery 创建动态的 Facebook“赞”按钮。但是,我遇到了一个不断重复的错误。
我创建按钮的 jQuery 是:
$('#fbLike').html('<fb:like href="'+url+'" send="false" layout="button_count" width="80" show_faces="true" />');
FB.XFBML.parse(document.getElementById('fbLike'));
但是,我收到以下错误:
Blocked a frame with origin "https://www.facebook.com" from accessing
a frame with origin "http://localhost:8888". The frame requesting
access has a protocol of "https", the frame being accessed has a
protocol of "http". Protocols must match.
有什么想法吗?
编辑
(函数(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; 如果(d.getElementById(id))返回; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/all.js#xfbml=1"; fjs.parentNode.insertBefore(js, fjs); }(文档, '脚本', 'facebook-jssdk'));
最佳答案
发生这种情况是因为协议(protocol)不匹配。
您正在尝试在 http 页面中创建 https 框架。
由于您的浏览器禁用了混合内容,您会看到该错误。
您可以通过命令行参数在 google chrome 上启用混合内容。
chrome.exe --allow-running-insecure-content
关于jquery - Facebook 点赞按钮错误 - 被阻止的框架,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16763428/