如何让 Facebook 的点赞按钮在作为页面登录时不显示 [英] How To Make The Facebook Like Button Display None When Logged In As Page

查看:13
本文介绍了如何让 Facebook 的点赞按钮在作为页面登录时不显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的网站上有 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 代码并使用一些 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/nouveau/pen/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
});

工作示例

请注意,您可能会遇到负载竞争.如果脚本在小部件加载之前运行,则此方法可能会失败...

Be aware you may run into a load-race. If the script runs before the widget loads this method may fail...

这篇关于如何让 Facebook 的点赞按钮在作为页面登录时不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆