Skip to content

Instantly share code, notes, and snippets.

@tzuryby
Last active December 21, 2015 01:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tzuryby/6230282 to your computer and use it in GitHub Desktop.
Save tzuryby/6230282 to your computer and use it in GitHub Desktop.
<div id="share-buttons"></div>
<style type="text/css">
#share-buttons img {
width: 25px;
padding: 5px;
border: 0;
box-shadow: 0;
display: inline;
}
</style>
<script type="text/javascript">
var services = {
"facebook": ["http://www.facebook.com/sharer.php?u=", "//d3rpgqg3n03ok.cloudfront.net/share-images/facebook.png"],
"twitter": ["http://twitter.com/share?url=", "//d3rpgqg3n03ok.cloudfront.net/share-images/twitter.png"],
"google+": ["https://plus.google.com/share?url=", "//d3rpgqg3n03ok.cloudfront.net/share-images/google.png"],
"linkedin": ["http://www.linkedin.com/shareArticle?mini=true&url=", "//d3rpgqg3n03ok.cloudfront.net/share-images/linkedin.png"]
},
button_bar = document.getElementById("share-buttons");
for (service_name in services) {
var service = services[service_name],
a = document.createElement("a"),
img = document.createElement("img");
a.href = service[0] + document.location.href;
a.target = "_blank";
img.src = service[1]
a.appendChild(img)
button_bar.appendChild(a)
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment