How To Make The Facebook Like Button Display None When Logged In As Page

前端 未结 4 1527
余生分开走
余生分开走 2021-01-25 03:56

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

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-25 03:59

    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...

提交回复
热议问题