Not yet rated

Problem

Place simple social networking share buttons on my website

Solution

Created a simple JavaScript file with the corresponding HTML links to share my website on popular social networking websites without including a "count"

Detailed explanation

Here is the appropriate JavaScript and HTML code to create these links.  Save the JavaScript as an external file (I used social.js) and link it, as it is in the example, to your webpage.

social.js =

        function facebook(url, title, desc, img) {
window.open( "http://www.facebook.com/sharer.php?s=100&p[title]="+encodeURI(title)+"&p[summary]=" +desc+ "&p[url]="+encodeURI(url)+"&p[images][0]="+encodeURI(img), "facebook", "status=1, height=400, width=550, resizable=0, toolbar=0");
facebook.focus();
}

function linkedIn(url, title, desc, source) {
window.open( "http://www.linkedin.com/shareArticle?mini=true&url=" + encodeURI(url) +"&title=" + encodeURI(title) + "&summary=" + encodeURI(desc) + "&source=" + encodeURI(source), "linkedIn", "status=1, height=400, width=550, resizable=0, toolbar=0");
linkedIn.focus();
}

function tweet(url, text) {
window.open( "https://twitter.com/intent/tweet?text=" + encodeURI(text) + "&url=" + encodeURI(url), "tweet", "status=1, height=400, width=550, resizable=0, toolbar=0");
tweet.focus();
}

function plusone(url) {
window.open( "https://plusone.google.com/_/+1/confirm?hl=en&url=" + encodeURI(url), "plusone", "status=1, height=400, width=550, resizable=0, toolbar=0");
plusone.focus();
}
  
social.html = 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
 
<!-- link to social.js -->
 
<script type="text/javascript" src="social.js">
</script>
 
</head>
 
<body>
 
<b>linkedIn (delete this line)</b>
<br />
usage: linkedIn(url, title, description, source) (delete this line) <br />
<a href="javascript:void(0)" onclick="linkedIn('cookbooks.adobe.com', 'Cookbooks', 'Easy JavaScript', 'source');">LinkedIn (insert image / button here)</a>
<br />
 
<b>Facebook (delete this line)</b>
<br />
usage: facebook(url, title, description, image_url) (delete this line)<br />
<a href="javascript:void(0)" onclick="facebook('cookbooks.adobe.com', 'Cookbooks', 'Easy JavaScript', 'INSERT IMAGE URL HERE');">Facebook (insert image / button here)</a>
<br />
 
<b>Google+ (delete this line)</b>
<br />
usage: plusone(url) (delete this line) <br />
<a href="javascript:void(0)" onclick="plusone('http://cookbooks.adobe.com'); return false;">Google+ one (insert image / button here)</a>
<br />
 
<b>Twitter (delete this line)</b>
<br />
usage: tweet(url, description) (delete this line) <br />
<a href="javascript:void(0)" onclick="tweet('cookbooks.adobe.com', 'Check out this easy recipe!');">Twitter (insert image / button here)</a>
 
 
</body>
</html>

+
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License. Permissions beyond the scope of this license, pertaining to the examples of code included within this work are available at Adobe.

Report abuse

Related recipes