hoho,搜集整理了非常全的主流分享到代码
这些分享到代码和图标花了我很长时间去整理的,主要用在利得丰丝光厂的网站上,网上要么有些代码找不到,要么就是有些代码有误,这些都是需要花时间整理的,当然,这些图标也都是要一个一个去找的。现在基本上主流的社会化站点的分享到代码都有了,其他的放再多也没什么意思,其实当初相放这些代码主要是感觉网站上空空的,想用这些图标来装点一下网站,同时也赶一下时髦。我收集整理的这些代码,不需要调用第三方的Js文件和图标,图标的链接都有,有需要的人可以把那些图标下载下去再长传到自己的网站空间,最好不要直接链接利得丰网站的图标(注意域名:www.lidefeng.cn),因为这样对大家都不好,各自网站的速度都会受影响,代码中把图标的地址出来主要是为了方便别人下载。
效果可以打开个页面看看:http://www.lidefeng.cn/archives/1387
代码很长,如果觉得不美观的话,可以做成一个外部js文件来调用。下面就是我们需要的代码。
<div id="shareto">
<script type="text/javascript">
var htmltitle=document.title;
var htmlurl=document.location.href;
</script>
<span class="txt" style="font-size:18px"><strong>分享到:</strong></span>
<span><span><a href="javascript:void(window.open('http://v.t.sina.com.cn/share/share.php?title='+encodeURIComponent(htmltitle)+'&url='+encodeURIComponent(htmlurl)));" title="分享到新浪微博"><img src="http://www.lidefeng.cn/wp-content/themes/tcl/images/website_icons/16/png/16x16-sina.png" alt="转播到新浪微博" /></a></span></span>
<span><a href="javascript:void(0)" onclick="postToWb();return false;" style="height:16px;font-size:12px;line-height:16px;" title="分享到腾讯微博"><img src="http://www.lidefeng.cn/wp-content/themes/tcl/images/website_icons/16/png/qq-weiboicon16.png" alt="转播到腾讯微博" /></a><script type="text/javascript">
function postToWb(){
var _url = encodeURIComponent(document.location);
var _assname = encodeURI("\//你注册的帐号,不是昵称
var _appkey = encodeURI("appkey\//你从腾讯获得的appkey
var _pic = encodeURI('\//(例如:var _pic='图片url1|图片url2|图片url3....)
var _t = '';//标题和描述信息
var metainfo = document.getElementsByTagName("meta\
for(var metai = 0;metai < metainfo.length;metai++){
if((new RegExp('description','gi')).test(metainfo[metai].getAttribute("name"))){
_t = metainfo[metai].attributes["content"].value;
}
}
_t = document.title+_t;//请在这里添加你自定义的分享内容
if(_t.length > 120){
_t= _t.substr(0,117)+'...';
}
_t = encodeURI(_t);
var _u = 'http://share.v.t.qq.com/index.php?c=share&a=index&url='+_url+'&appkey='+_appkey+'&pic='+_pic+'&assname='+_assname+'&title='+_t;
window.open( _u,'', 'width=700, height=680, top=0, left=0, toolbar=no, menubar=no, scrollbars=no, location=yes, resizable=no, status=no' );
}
</script> </span>
<span><a href="javascript:void(window.open('http://www.douban.com/recommend/?title=='+encodeURIComponent(htmltitle)+'&url='+encodeURIComponent(htmlurl)));" title="分享到豆瓣"><img src="http://www.lidefeng.cn/wp-content/themes/tcl/images/website_icons/16/png/16-douban.png" alt="分享到豆瓣" /></a></span>
<span><a href="javascript:void(window.open('http://cang.baidu.com/do/add?it='+encodeURIComponent(htmltitle)+'&iu='+encodeURIComponent(htmlurl)+'&fr=ien#nw=1'));" title="分享到百度搜藏"><img src="http://www.lidefeng.cn/wp-content/themes/tcl/images/website_icons/16/png/16-baidu.png" alt="收藏到百度搜藏" /></a></span>
<span><a href="javascript:void(window.open('http://apps.hi.baidu.com/share/?url='+encodeURIComponent(document.location.href)));" title="分享到百度空间"><img src="http://www.lidefeng.cn/wp-content/themes/tcl/images/website_icons/16/gif/icon_baidu.gif" alt="分享到百度空间" /></a></span>
<span><a href="javascript:void(window.open('http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?title='+encodeURIComponent(htmltitle)+'&url='+encodeURIComponent(htmlurl)));" title="分享到QQ空间"><img src="http://www.lidefeng.cn/wp-content/themes/tcl/images/website_icons/16/png/16-qzone.png" alt="分享到QQ空间" /></a></span>
<span><a href="javascript:var b=document.body;var GR________bookmarklet_domain=' http://www.google.com';if(b&&!document.xmlVersion){void(z=document.createElement('script'));void(z.src='http://www.google.com/reader/ui/link-bookmarklet.js\void(b.appendChild(z));}else{}" title="分享到Google Reader"><img src="http://www.lidefeng.cn/wp-content/themes/tcl/images/website_icons/16/png/16-google.png" alt="分享到Google Reader" /></a></span>
<span><a href="javascript:(function(){window.open('http://t.163.com/article/user/checkLogin.do?link=http://news.163.com/&source='+'利得丰'+ '&info='+encodeURIComponent(document.title)+' '+encodeURIComponent(location.href),'_blank','width=510,height=300\})()" title="分享到网易微博"><img src="http://www.lidefeng.cn/wp-content/themes/tcl/images/website_icons/16/png/16-163weibo.png" alt="转播到网易微博" border="0" /></a></span>
<span><a href="javascript:var d=document,w=window,f='http://fanfou.com/share',l=d.location,e=encodeURIComponent,p='?u='+e(l.href)+'?t='+e(d.title)+'?d='+e(w.getSelection?w.getSelection().toString():d.getSelection?d.getSelection():d.selection.createRange().text)+'?s=bl';if(!w.open(f+'r'+p,'sharer','toolbar=0,status=0,width=600,height=400')){l.href=f+'.new'+p;}void(0)" title="分享到饭否"><img src="http://www.lidefeng.cn/wp-content/themes/tcl/images/website_icons/16/gif/16-fanfou.gif" alt="分享到饭否" /></a></span>
<span><a href="javascript:void(window.open('http://share.renren.com/share/buttonshare?title='+encodeURIComponent(htmltitle)+'&link='+encodeURIComponent(htmlurl)));" title="分享到人人网"><img src="http://www.lidefeng.cn/wp-content/themes/tcl/images/website_icons/16/png/16-renren.png" alt="分享到人人网" /></a></span>
<span><a href="javascript:void(window.open('http://www.xianguo.com/service/submitdigg/?title='+encodeURIComponent(htmltitle)+'&link='+encodeURIComponent(htmlurl)));" title="分享到鲜果"><img src="http://www.lidefeng.cn/wp-content/themes/tcl/images/website_icons/16/png/16-xianguo.png" alt="分享到鲜果" /></a></span>
<span><a href="javascript:void(window.open('http://www.kaixin001.com/repaste/share.php?rtitle='+encodeURIComponent(htmltitle)+'&rurl='+encodeURIComponent(htmlurl)));" title="分享到开心网"><img src="http://www.lidefeng.cn/wp-content/themes/tcl/images/website_icons/16/png/16-kaixin001.png" alt="分享到开心网" /></a></span>
<span><a href="javascript:window.open('http://twitter.com/home?status='+encodeURIComponent(document.location.href)+' '+encodeURIComponent(document.title));void(0)" title="分享到twitter"><img src="http://www.lidefeng.cn/wp-content/themes/tcl/images/website_icons/16/png/twitter.png" alt="分享到twitter" /></a></span>
<span><a href="javascript:window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(document.location.href)+'&t='+encodeURIComponent(document.title));void(0)" title="分享到facebook"><img src="http://www.lidefeng.cn/wp-content/themes/tcl/images/website_icons/16/png/16-facebook.png" alt="分享到facebook" /></a></span>
<span><a href="javascript:window.open('http://del.icio.us/post?url='+encodeURIComponent(document.location.href)+'&title='+encodeURIComponent(document.title)+'¬es=\void(0)" title="分享到delicious书签"><img src="http://www.lidefeng.cn/wp-content/themes/tcl/images/website_icons/16/gif/16-delicious.gif" alt="分享到delicious书签" /></a></span>
<span><a href="javascript:void(window.open('http://profile.live.com/badge?url='+encodeURIComponent(document.location.href)));" title="分享到msn"><img src="http://www.lidefeng.cn/wp-content/themes/tcl/images/website_icons/16/png/SharingBadge16x16White.png" alt="分享到msn" /></a></span>
<span><a style="text-decoration:none;" href="http://www.yahoo.com/" onclick="window.open('http://myweb2.search.yahoo.com/myresults/bookmarklet?t='+encodeURIComponent(document.title)+'&d=&tag=&u='+encodeURIComponent(location.href));return false;" title="分享到yahoo书签"> <img src="http://www.lidefeng.cn/wp-content/themes/tcl/images/website_icons/16/jpg/16-yahoo.jpg" alt="Add to: Yahoo" name="Yahoo" width="16" height="16" border="0" id="Yahoo"></a></span>
<span><a href="javascript:void(0)" onclick="javascript:window.open('http://share.jianghu.taobao.com/share/addShare.htm?title='+encodeURIComponent(document.title.substring(0,76))+'&url='+encodeURIComponent(location.href)+'&content=','_blank\ void 0" title="分享到淘宝网"><img src="http://www.lidefeng.cn/wp-content/themes/tcl/images/website_icons/16/png/16-taobao.png" / alt="分享到淘宝网"></a></span>
<span><a title="分享到搜狐微博" href="javascript:void((function(s,d,e,r,l,p,t,z,c){var f='http://t.sohu.com/third/post.jsp?',u=z||d.location,p=['&url=',e(u),'&title=',e(t||d.title),'&content=',c||'gb2312','&pic=',e(p||'')].join('\function%20a(){if(!window.open([f,p].join(''),'mb',['toolbar=0,status=0,resizable=1,width=660,height=470,left=',(s.width-660)/2,',top=',(s.height-470)/2].join('')))u.href=[f,p].join('\};if(/Firefox/.test(navigator.userAgent))setTimeout(a,0);else%20a();})(screen,document,encodeURIComponent,'','','','','','utf-8'));" style="margin:0 0 0 0;font-size:12px;font-family:'\5b8b\4f53';color:#369"><img src="http://www.lidefeng.cn/wp-content/themes/tcl/images/website_icons/16/gif/16icon-sohu.gif" width="16" height="16" alt="分享到搜狐微博"/></a></span>
<span><a href="javascript:window.open('http://space.feixin.10086.cn/api/share?source='+'利得丰纺织在线'+'&title='+encodeURIComponent(document.title)+'&url='+encodeURIComponent(document.location.href));void(0)" title="分享到飞信"><img src="http://www.lidefeng.cn/wp-content/themes/tcl/images/website_icons/16/jpg/14x14-feixin.jpg" alt="分享到飞信" width="16" height="16" /></a></span>
<script type="text/javascript" charset="utf-8">(function(){
var param = {
strFlashPageURL:location.href, /**转发帖子原地址*/
strTitle:document.title, /**转发的帖子主题(可选,默认为所在页面的title)*/
strContent:'', /**转发帖子的内容,可以用@添加关联用户(可选)*/
strFlashURL:'', /**转发帖子的视频地址(可选)*/
pIMG:'', /**转发帖子的图片地址(可选)*/
itemtype:'tech', /**转发板块类型*/
item:'402', /**转发板块ID*/
}
var temp = [];
for( var p in param ){
temp.push(p + '=' + encodeURIComponent( param[p] || '' ) )
}
document.write('<a target="_blank" href="http://www.tianya.cn/new/share/compose.asp?' + temp.join('&') +'" title="分享到天涯社区"><img src="http://www.lidefeng.cn/wp-content/themes/tcl/images/website_icons/16/png/tianya-16.png" alt="分享到天涯社区"></a>')
})()
</script>
<span><a class="fav_google" href="javascript:window.open('http://www.google.com/bookmarks/mark?op=add&bkmk='+encodeURIComponent(document.location.href)+'&title='+encodeURIComponent(document.title));void(0)" title="分享到Google Bookmarks"><img src="http://www.lidefeng.cn/wp-content/themes/tcl/images/website_icons/16/png/Google Bookmarks_64x64.png" height="16" width="16" alt="分享到Google Bookmarks"/></a></span>
<span><a href="javascript: void(window.open('http://www.google.com/buzz/post?url='.concat(encodeURIComponent(location.href)) ));"><img title="分享到Google Buzz!" src="http://www.lidefeng.cn/wp-content/themes/tcl/images/website_icons/16/png/google-buzz-16x16.png" alt="分享到Google Buzz"/></a></span>
<spain class="share_tieba"><a href="javascript:;" title="分享到i贴吧" onclick="void(function(){var d=document,e=encodeURIComponent,u='http://tieba.baidu.com/i/app/open_share_api?link='+e(d.location.href),o=function(){if(!window.open(u))location.href=u};if(/Firefox/.test(navigator.userAgent)){setTimeout(o,0)}else{o()};return false;})();"><img src="http://www.lidefeng.cn/wp-content/themes/tcl/images/website_icons/16/jpg/s_logo_itieba.jpg" alt="分享到i贴吧" width="16" height="16"/></a> </spain>
</div>