Skip to main content

Facebook Like-Button - hide count?


In the setup dialog for the Like-Button, there are only two options for layout:




  • Alternative 1


  • Alternative 2



Unfortunately, the numbers for the website of my employer is nowhere near 22'000, so the powers that be have decided that we should not show the number of "likes" until said number is a little more in our favour. As far as I know, I don't have access to the layout of the button through Javascript or CSS (it's in an iframe served by facebook). Are there any other ways to hide the count?


Source: Tips4allCCNA FINAL EXAM

Comments

  1. Silly Rabbit is correct.
    Dont resize the Iframe, that can be detected from within the page.
    Use the iframe code provided by facebook at http://developers.facebook.com/docs/reference/plugins/like

    then wrap it in a div with height and width and overflow hidden.
    this cannot be detected from within tha page if you dont have some other facebook javascript or xss reciever stuff on your page

    ReplyDelete
  2. If you do overflow:hidden then keep in mind that it will also hide the comment box that comes up in XFBML version... afer user likes it. So best if you do this...

    /* make the like button smaller */
    .fb_edge_widget_with_comment iframe
    {
    width:47px !important;
    }

    /* but make the span that holds the comment box larger */
    span.fb_edge_comment_widget.fb_iframe_widget iframe
    {
    width:401px !important;
    }

    ReplyDelete
  3. Accepted answer is good, but be careful with multilingual pages. The text differ in length:

    English: Like

    Dutch: Vind ik leuk

    German: Gefällt mir

    Just a heads up.

    ReplyDelete
  4. Just encompass the iframe in a div set the width to the width of button, set overflow to hidden
    i.e.

    <div style="width:52px;overflow:hidden;">
    <fb:like layout="button_count"></fb:like>

    <div id="fb-root"></div>
    <script>
    window.fbAsyncInit = function() {
    FB.init({appId: 'YOUR_APP_ID', status: true, cookie: true,
    xfbml: true});
    };
    (function() {
    var e = document.createElement('script');
    e.type = 'text/javascript';
    e.src = document.location.protocol +
    '//connect.facebook.net/en_US/all.js';
    e.async = true;
    document.getElementById('fb-root').appendChild(e);
    }());
    </script>
    </div>

    ReplyDelete
  5. If you're using Facebook's javascript like button (so you can capture like events), here's what we had to do:

    Due to a change Facebook recently made in the way comment dialogs display, we had to change how we were hiding it. The way they show the comment dialog has been 'moving' the content inside of the my overflow:hidden element so that the button looks really odd to the user after they click the like button.

    In addition to adding a wrapping element with an 'overflow:none' style, you will need to hide the comment element that Facebook is putting onto your page:

    Styles:

    span.no_overflow {
    overflow: none;
    width: 50px;
    }

    .no_overflow span.fb_edge_comment_widget.fb_iframe_widget {
    display: none;
    }


    Markup:

    <span class="no_overflow">
    <fb:like></fb:like>
    </span>


    We're still using the fb:like markup though. I have not tested this with the new div-based markup that Facebook is providing on their site now.

    ReplyDelete
  6. Adding the following to your css should hide the text element for users and keep FB Happy

    .connect_widget_not_connected_text
    {
    display:none !important; /*in your stylesheets to hide the counter!*/
    }


    -- Update

    Try using a different approach.

    http://www.facebook.com/share/

    ReplyDelete
  7. My solution is a little hood but it works what I do is just basically detect where the number is going to be and use css to have a box cover over it. I guess you can also cheat the system and add more hits if you wanted. here is my code using jquery but it will be different than others depending on where you place the like button on your page.

    Not the most glamorous but hey the security is to tight to manipulate content in side of a frame.




    var facebook_load = '';
    $(document).ready(function() {
    facebook_load = setInterval('checkIframeFacebookLoad()',100);
    });

    function checkIframeFacebookLoad() {
    if($('iframe.fb_ltr').length) {
    var parent = $('iframe.fb_ltr').parent();
    var hide_counter = $('').attr('id', 'hide_count');
    parent.append(hide_counter);
    clearInterval(facebook_load);
    }
    }



    #hide_count {
    position:absolute;
    top:-8px;
    left:122px;
    background:#becdd5;
    padding:5px 10px;
    }

    ReplyDelete
  8. This is what I've tried and it works fine in ff, chrome and ie8:

    /* set width for the <fb:like> tag */

    .fb-button {
    width:51px;
    }

    /* set width for the iframe below, to hide the count label*/

    .fb-button iframe{
    width:45px!important;
    }

    ReplyDelete
  9. I know many solutions have been posted already, but mine is still somewhat different. It works for the HTML5 Version of the like button and only uses css to hide the count box. Don't forget to add the appId to test.

    CSS:

    <style type="text/css">
    .fb-like span {
    display: block;
    height: 22px;
    overflow: hidden;
    position: relative;
    width: 140px /* set this to fit your needs when support international sites */;
    }

    .fb-like iframe {
    height: 62px;
    overflow: hidden;
    position: absolute;
    top: -41px;
    width: 55px;
    }
    </style>


    FB Like Button:

    <div id="fb-root"></div>
    <script>(function(d, s, id) {
    var js, fjs = d.getElementsByTagName(s)[0];
    if (d.getElementById(id)) return;
    js = d.createElement(s); js.id = id;
    js.src = "//connect.facebook.net/en_GB/all.js#xfbml=1&appId=xxxxxxxxxxxx";
    fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));</script>

    <div class="fb-like" data-send="true" data-layout="box_count" data-width="450" data-show-faces="false"></div>

    ReplyDelete
  10. All you need to do is edit the iframe code that facebook gives you and change the width to 47 (you need to change it in 2 places). Seems to work perfectly for me so far.

    ReplyDelete

Post a Comment

Popular posts from this blog

Why is this Javascript much *slower* than its jQuery equivalent?

I have a HTML list of about 500 items and a "filter" box above it. I started by using jQuery to filter the list when I typed a letter (timing code added later): $('#filter').keyup( function() { var jqStart = (new Date).getTime(); var search = $(this).val().toLowerCase(); var $list = $('ul.ablist > li'); $list.each( function() { if ( $(this).text().toLowerCase().indexOf(search) === -1 ) $(this).hide(); else $(this).show(); } ); console.log('Time: ' + ((new Date).getTime() - jqStart)); } ); However, there was a couple of seconds delay after typing each letter (particularly the first letter). So I thought it may be slightly quicker if I used plain Javascript (I read recently that jQuery's each function is particularly slow). Here's my JS equivalent: document.getElementById('filter').addEventListener( 'keyup', function () { var jsStart = (new Date).getTime()...

Is it possible to have IF statement in an Echo statement in PHP

Thanks in advance. I did look at the other questions/answers that were similar and didn't find exactly what I was looking for. I'm trying to do this, am I on the right path? echo " <div id='tabs-".$match."'> <textarea id='".$match."' name='".$match."'>". if ($COLUMN_NAME === $match) { echo $FIELD_WITH_COLUMN_NAME; } else { } ."</textarea> <script type='text/javascript'> CKEDITOR.replace( '".$match."' ); </script> </div>"; I am getting the following error message in the browser: Parse error: syntax error, unexpected T_IF Please let me know if this is the right way to go about nesting an IF statement inside an echo. Thank you.