Last active
December 16, 2015 13:29
-
-
Save guillaumepiot/5442196 to your computer and use it in GitHub Desktop.
SOCIAL - Twitter share
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// We bind a new event to our link | |
$('a.tweet').click(function(e){ | |
//We tell our browser not to follow that link | |
e.preventDefault(); | |
//We get the URL of the link | |
var loc = $(this).attr('href'); | |
//We get the title of the link | |
var title = encodeURIComponent($(this).attr('title')); | |
//We trigger a new window with the Twitter dialog, in the middle of the page | |
window.open('http://twitter.com/share?url=' + loc + '&text=' + title + '&', 'twitterwindow', 'height=450, width=550, top='+($(window).height()/2 - 225) +', left='+$(window).width()/2 +', toolbar=0, location=0, menubar=0, directories=0, scrollbars=0'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Good Script. I updated this script to either include the URL of the link or the URL of the location.
See lines 7-10 to see what i am talking about - https://gist.github.com/BryanBarrera/a05f4a6beb00c0555fae