Skip to content

Instantly share code, notes, and snippets.

@plamere
Created November 27, 2012 11:23
Show Gist options
  • Save plamere/4153748 to your computer and use it in GitHub Desktop.
Save plamere/4153748 to your computer and use it in GitHub Desktop.
dynamically adapting the tweet button
<body>
The tweet button:
<span id='tweet-span'>
<a href="https://twitter.com/share" id='tweet'
class="twitter-share-button"
data-lang="en"
data-count='none'>Tweet</a>
<script>!function(d,s,id){varjs,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="https://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</span>
<script>
function tweetSetup() {
$(".twitter-share-button").remove();
var tweet = $('<a>')
.attr('href', "https://twitter.com/share")
.attr('id', "tweet")
.attr('class', "twitter-share-button")
.attr('data-lang', "en")
.attr('data-count', "none")
.text('Tweet');
$("#tweet-span").prepend(tweet);
tweet.attr('data-text', "#InfiniteJukebox of " + t.fixedTitle);
tweet.attr('data-url', document.URL);
twttr.widgets.load();
}
</script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment