更新:所以这是很大的。如果您尝试使用类似按钮链接到任何Facebook页面,则不起作用。尝试去Facebook的创建页面(http://developers.facebook.com/docs/reference/plugins/like/)并输入任何Facebook页面的URL(如Stackoverflow的:http://www.facebook.com/stackoverflowpage)。Facebook Like button显示0赞赞所有Facebook页面
此代码工作正常,直到今天早些时候,现在我完全失去了为什么它已停止工作。类似的按钮加载,但你不能喜欢它,或发送一条消息,它的计数是0(它应该在350左右)。
这是jsfiddle。这很简单:http://jsfiddle.net/rqR6C/
每隔一段时间,只有谷歌浏览器的控制台中出现错误。我发现其他一些人也遇到了同样的错误信息,他们也说这是间歇性的。这里的错误:
The frame requesting access set 'document.domain' to 'facebook.com', but the frame being accessed did not. Both must set 'document.domain' to the same value to allow access.
代码:
<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
// Init the SDK upon load
window.fbAsyncInit = function() {
FB.init({
appId : '464723870207650', // App ID
channelUrl : '//'+window.location.hostname+'/channel.php', // Path to your Channel File
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true, // parse XFBML
frictionlessRequests: true
});
}
// Load the SDK Asynchronously
(function(d){
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
ref.parentNode.insertBefore(js, ref);
}(document));
</script>
<div class="fb-like" data-href="http://facebook.com/pages/Grouptonescom/160798537354204" data-send="true" data-layout="button_count" data-width="180" data-show-faces="false"></div>
你的'fb-root' div在哪里?浏览器控制台中是否有任何错误消息? – Phil
此外,可能只是与在jsfiddle上托管代码有关,但我看到此错误消息; “应用程序配置不允许给定URL:应用程序的设置不允许使用一个或多个给定的URL,它必须与网站URL或Canvas URL匹配,或者该域必须是其中一个应用程序域的子域“。 – Phil
该错误只发生在谷歌浏览器中,间歇性发生。我无法让它出现在Safari的控制台上。我在chrome中添加了fb-root和我的控制台我遇到了这个错误:请求访问的框架将'document.domain'设置为'facebook.com',但被访问的框架没有。两者都必须将'document.domain'设置为相同的值以允许访问 – Colin