Skip to content

Instantly share code, notes, and snippets.

@arlg
Created February 19, 2013 16:45
Show Gist options
  • Save arlg/4987597 to your computer and use it in GitHub Desktop.
Save arlg/4987597 to your computer and use it in GitHub Desktop.
Facebook, Twitter, G+ single/multiple shares
NS.Shares = {
facebook : function(_title, _summary, _url, _image) {
window.open('http://www.facebook.com/sharer.php?s=100&p[title]='+encodeURIComponent(_title)+'&p[summary]='+encodeURIComponent(_summary)+'&p[url]='+encodeURIComponent(_url)+'&&p[images][0]='+encodeURIComponent(_image),'sharer','toolbar=0,status=0,width=548,height=325');
},
twitter : function(_tweet, _url){
window.open('http://twitter.com/home?status='+_tweet+' - '+_url, 'tweet','toolbar=0,status=0,width=548,height=325');
},
google : function(_url){
window.open('https://plus.google.com/share?url='+_url, 'share','toolbar=0,status=0,width=548,height=325');
}
};
//In your HTML :
<a onClick="return NS.Shares.facebook('Title share', 'summary share', location.href, 'http://st-listas.20minutos.es/images/2011-04/284073/2959190_640px.jpg')" href="javascript: void(0)">Facebook Share</a>
<a onCLick="return NS.Shares.twitter('tweet text', location.href)" href="javascript: void(0)">Twitter share</a>
<a onCLick="return NS.Shares.google(location.href)" href="javascript: void(0)">G+ share</a>
<!-- Email share -->
<a href="mailto:?subject=email subject&body=Hi,I found this website
and thought you might like it http://www.internet.com">Email share</a>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment