Skip to content

Instantly share code, notes, and snippets.

@alana314
Created August 25, 2016 23:45
Show Gist options
  • Save alana314/f81e083fcfa532d6842014b0d70501c4 to your computer and use it in GitHub Desktop.
Save alana314/f81e083fcfa532d6842014b0d70501c4 to your computer and use it in GitHub Desktop.
jQuery tweet button function using the window URL and content from twitter's meta tag
$('a.sharebutton.twitter').click(function(e){
window.open("https://twitter.com/intent/tweet?text=" + encodeURIComponent($('meta[name="twitter:description"]').attr('content').substring(0, 116)) + "&url=" + encodeURIComponent(window.location.href),"tweet", "width=500,height=300");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment