Posted By

pratheep on 08/24/11


Tagged

twitter facebook


Versions (?)

Share Facebook and Twitter


 / Published in: JavaScript
 

Share current page on Facebook wall or Twitter

  1. function share(type) {
  2. var url = window.location.href;
  3. var title = window.document.title;
  4. if(type == 'facebook') {
  5. window.open("http://www.facebook.com/share.php?src=bm&u=" + url + "&t=" + title);
  6. }else if(type == 'twitter') {
  7. window.open("http://twitter.com/home?status=" + url);
  8. }
  9. }
  10.  
  11.  
  12. <a href="#" onclick="share('facebook');">Facebook</a>
  13. <a href="#" onclick="share('twitter');">Twitter</a>

Report this snippet  

You need to login to post a comment.