Free Light weight Social media sharing javascript for Facebook, Twitter, Stumble Upon, Digg and Reddit
Social Media Buttons or buttons that help you share the content on bookmarking websites such as Stumble Upon, Reddit or Digg or social networking Websites such as Facebook or Twitter. Adding the buttons helps you to expose your content to a broader audience.
There are lots of social media button providers such as AddThis or ShareThis. I think it is overloaded with features that makes your page load slow as well as bring in unintentional 3rd party javascript code ( or flash tracker ) which runs on your blog.
So it is always safe to use your own script or scripts which you can read understand and verify it just does what it is suppose to do.
Javascript Object for Social Media Sharing
var share = { fb:function(title,url) { this.share('http://www.facebook.com/sharer.php?u=##URL##&t=##TITLE##',title,url); }, tw:function(title,url) { this.share('http://twitter.com/home?status=##URL##+##TITLE##',title,url); }, su:function(title,url){ this.share('http://www.stumbleupon.com/submit?url=##URL##',title,url); }, reddit:function(title,url){ this.share('http://www.reddit.com/submit?url=##URL##',title,url); }, digg:function(title,url){ this.share('http://digg.com/submit?phase=2&url=##URL##&title=##TITLE##',title,url); }, share:function(tpl,title,url) { if(!url) url = encodeURIComponent(window.location); if(!title) title = encodeURIComponent(document.title); tpl = tpl.replace("##URL##",url); tpl = tpl.replace("##TITLE##",title); window.open(tpl,"sharewindow"+tpl.substr(6,15),"width=640,height=480"); } };
The share javascript object is used for social media sharing. In its simplest usage all you have to do is call share.tw(), to open a popup that shows twitter page.
Documentation
Functions
share.tw(); for posting to Twitter
share.fb(); for posting to Facebook
share.su(); for posting Stumble Upom
share.digg(); for posting to Digg
share.reddit(); for posting to Reddit.
By default the title of the current page and url of the current page are passed as arguments if you dont specify any.
Minified Code and Installation
var share={fb:function(a,b){this.share("http://www.facebook.com/sharer.php?u=##URL##&t=##TITLE##",a,b)},tw:function(a,b){this.share("http://twitter.com/home?status=##URL##+##TITLE##",a,b)},su:function(a,b){this.share("http://www.stumbleupon.com/submit?url=##URL##",a,b)},reddit:function(a,b){this.share("http://www.reddit.com/submit?url=##URL##",a,b)},digg:function(a,b){this.share("http://digg.com/submit?phase=2&url=##URL##&title=##TITLE##",a,b)},share:function(a,b,c){c||(c=encodeURIComponent(window.location)); b||(b=encodeURIComponent(document.title));a=a.replace("##URL##",c);a=a.replace("##TITLE##",b);window.open(a,"sharewindow"+a.substr(6,15),"width=640,height=480")}};
Copy paste the above code to any of your javascript files or add a new file or include it in your html source. (
<script> //The above code here. </script>
Use onclick events of Buttons or Images to fire the functions.
For more check out the buttons below ...
- Perl Read Media File
- Virus Changes Javascript Files
- What Is Used To Compress Google Javascript
- Gumblar And Bagle Web Javascript Virus
- Php Mysql Javascript Engineer Yahoo! Resume
- Bootloader Is Undefined Facebook
- Youtube Virus Facebook
- Google Dns Block Facebook
- Facebook Application Using Codeigniter Backend
- Php Page Scrape Facebook
- Facebook Orkut Xss Tricks
- Facebook Is Blocked On My Computer On System Folders
- Free Screenshot
- Free T9 Dictionary Code
- Free Jquery Code Dashboard

Comments
Post new comment