Tuesday 20 December 2011

How to customize facebook share and like button

Copy the following code in your html page.

Example : Customize facebook share button. 

  1. <script>  
  2. function fbs_click(share_this) {  
  3. var txtLink = document.getElementById(share_this);  
  4. var a = txtLink.getElementsByTagName('a');  
  5. if (a != null && a.length > 0) {  
  6.     var setLink = txtLink.parentNode.getElementsByTagName('a');  
  7.     if (setLink != null && setLink.length > 0) {  
  8.         t= a[0].title;  
  9.         u= a[0].href;  
  10.     }  
  11. }  
  12. window.open(u+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');return false;  
  13. }</script>  
  14. <div id="share_this">  
  15. <a href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fwww.phptechi.com/Fmagento-display-banners-for-category-page.html" type="box_count" onclick="return fbs_click('share_this')" title="phptechi" target="_blank">Share this</a>  
  16.   
  17. </div> 

No comments:

Post a Comment