Skip to content

Instantly share code, notes, and snippets.

@llkats
Created February 28, 2011 16:25
Show Gist options
  • Save llkats/847557 to your computer and use it in GitHub Desktop.
Save llkats/847557 to your computer and use it in GitHub Desktop.
custom Twitter button function
#custom-tweet-button {
width: 60px;
}
#custom-tweet-button a {
background: url('http://a4.twimg.com/images/favicon.ico') 1px center no-repeat;
border: 1px solid #ccc;
color: #437792;
display: block;
padding: 2px 5px 2px 20px;
text-decoration: none;
}
<div id="custom-tweet-button">
<a href="#" id="tweet">Tweet</a>
</div>
function tweetWindow(url) {
window.open("http://twitter.com/share?url=http%3A%2F%2Fwww.google.com", "tweet", "location=0,toolbar=0,directories=0,scrollbars=0,status=0,menubar=0,resizable=0,width=600,height=500");
}
function window_onload() {
var tweetbutton = document.getElementById("tweet");
if (tweetbutton.addEventListener) {
tweetbutton.addEventListener("click", tweetWindow, false);
} else if (tweetbutton.attachEvent) {
tweetbutton.attachEvent('onclick', tweetWindow);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment