-
-
Save anonymous/75240d0cedf76acd86b8a6bb971d5d01 to your computer and use it in GitHub Desktop.
Backlinko Click-to-tweet
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
$('a.clicktweet').click(function(event) { | |
event.preventDefault(); | |
var theText = encodeURIComponent($(this).attr('data-tweet')); | |
var theUrl = encodeURIComponent($(this).attr('data-url')); | |
var theVia = encodeURIComponent($(this).attr('data-via')); | |
var theEntireLink = | |
'https://twitter.com/share?url=' + | |
theUrl + | |
'&text=' + | |
theText + | |
'&via=' + | |
theVia; | |
window.open( | |
theEntireLink, | |
'twitter', | |
'width=600, height=300, top=' + | |
($(window).height() / 2 - 225) + | |
', left=' + | |
($(window).width() / 2 - 275) + | |
', directories=0, location=0, menubar=0, toolbar=0, scrollbars=0' | |
); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment