如何使Facebook的Like按钮显示无身份登录时页面 [英] How To Make The Facebook Like Button Display None When Logged In As Page
问题描述
我有Facebook的喜欢按钮,在我的网站 http://theganjagirls.com ......一切看起来和正常工作当我登录到我的Facebook帐户...但是当我登录的页面管理,像按钮Facebook的显示一个大的白色盒子里面发现一个开关的链接。香港专业教育学院看到这种情况发生在很多大网站,所以我知道它与Facebook的一个问题。
我只是去上teespring.com/ganjagirls,他们巧妙地使Facebook的喜欢按钮只显示:无当你登录的页面管理
I have the Facebook like button on my site http://theganjagirls.com ... everything looks and works fine when I'm logged into my Facebook account... But when I'm logged in as a page admin, the Facebook like button displays a "switch" link inside a big white box. Ive seen this happen on many big sites so I know its a problem with Facebook. I just went on to teespring.com/ganjagirls and they cleverly make the Facebook like button simply display:none when your logged in as a page admin.
所以我的问题是:如何让我的Facebook的喜欢按钮显示:无只在查看用户登录到Facebook的页面管理
So my question is: How do i make the Facebook like button display:none only if the viewing user is logged in to Facebook as a page admin?
我试图通过敲击在容器Facebook的code和使用一些JavaScript做我自己......但我的业余,我不能让它正常工作。
I tried to do it my self by rapping the Facebook code in a container and using some JavaScript... but I'm amateur and I couldn't get it to work properly.
下面是我在codePEN走到这一步:的http:// WWW。codepen.io /风格/笔/ zfcLu 。
Here is what I got so far in CodePen: http://www.codepen.io/nouveau/pen/zfcLu.
推荐答案
您可以使用一个小脚本设置超时功能,并检查控件的宽度
You could use a little script to set a timeout function and check the width of the widget
var timer;
$(window).load(function () {
window.clearTimeout(timer);
timer = window.setTimeout(function () {
if ($('.fb-like').width() === 0) {
$('.fb-like').hide();
console.log('face');
}
}, 1000); // using 1000 milliseconds to work around load race
});
Working Example
请注意您可能会遇到负载比赛。如果脚本小部件加载之前运行此方法可能会失败...
Be aware you may run into a load-race. If the script runs before the widget loads this method may fail...
这篇关于如何使Facebook的Like按钮显示无身份登录时页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!