/ Published in: JavaScript

Share current page on Facebook wall or Twitter
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function share(type) { var url = window.location.href; var title = window.document.title; if(type == 'facebook') { window.open("http://www.facebook.com/share.php?src=bm&u=" + url + "&t=" + title); }else if(type == 'twitter') { window.open("http://twitter.com/home?status=" + url); } } <a href="#" onclick="share('facebook');">Facebook</a> <a href="#" onclick="share('twitter');">Twitter</a>
Comments
