社会化分享按钮代码
之前使用过许多社会化分享的插件,后来转用Add Bookmarks插件,不过插件已经很老了,好多的按钮都已失效,而且又好多的估计已经没有在使用了。靠人不如靠自己,最终决定亲自对它进行大修。
其实挺简单的,根本不用插件,直接用代码就可以实现该功能。除了Twitter全是Java弹出窗口模式,尽管代码麻烦,但感觉弹出窗口模式很酷,我很喜欢。
使用方法:下载sharelink.7z,解压得到sharelink.php和sharelink文件夹,上传至主题根目录下,然后在主题合适的地方通过下面的代码调用。
<?php include(TEMPLATEPATH . '/sharelink.php'); ?>
【下载地址】:sharelink1.2.7z
Update:2010-09-22,添加了腾讯微博转发按钮。
Update:2010-07-02,更新为单独的php文件和图标文件夹,放到主题内,方便调用。
Update:新增了Google Buzz转发按钮。
sharelink.php里的代码如下:
<style type="text/css">
.sharelink {margin-right:3px;}
</style>
» 收藏+分享:
<!-- Delicious -->
<a href="http://delicious.com/save" onclick="window.open('http://delicious.com/save?v=5&noui&jump=close&url='+encodeURIComponent('<?php the_permalink() ?>')+'&title='+encodeURIComponent(document.title), 'delicious','toolbar=no,width=550,height=550,left=50,top=50,'); return false;"><img class="sharelink" title="收藏到Delicious" alt="Delicious" src="<?php bloginfo('template_url'); ?>/sharelink/delicious.ico" width="16" height="16" /></a>
<!-- Google -->
<a href="javascript:window.open('http://www.google.com/bookmarks/mark?op=add&bkmk='+encodeURIComponent('<?php the_permalink() ?>')+'&title='+encodeURIComponent(document.title)+'&jumpback=2&noui=1','favit','width=800,height=600,left=50,top=50,toolbar=no,menubar=no,location=no,scrollbars=yes,status=yes,resizable=yes');void(0)"><img class="sharelink" title="添加到Google书签" alt="Google" src="<?php bloginfo('template_url'); ?>/sharelink/google.ico" width="16" height="16" /></a>
<!-- Google Reader-->
<a href="javascript:var%20b=document.body;var%20GR________bookmarklet_domain='https://www.google.com';if(b&&!document.xmlVersion){void(z=document.createElement('script'));void(z.src='https://www.google.com/reader/ui/link-bookmarklet.js');void(b.appendChild(z));}else{}"><img class="sharelink" title="共享到Google Reader" alt="Google Reader" src="<?php bloginfo('template_url'); ?>/sharelink/googlereader.png" width="16" height="16" /></a>
<!-- facebook -->
<a href="javascript:window.open('http://www.facebook.com/share.php?u='+encodeURIComponent('<?php the_permalink() ?>')+'&t='+encodeURIComponent(document.title)+'&jumpback=2&noui=1','favit','width=800,height=600,left=50,top=50,toolbar=no,menubar=no,location=no,scrollbars=yes,status=yes,resizable=yes');void(0)"><img class="sharelink" title="分享到facebook" alt="facebook" src="<?php bloginfo('template_url'); ?>/sharelink/facebook.ico" width="16" height="16" /></a>
<!-- Live -->
<a href="javascript:window.open('https://skydrive.live.com/sharefavorite.aspx/.SharedFavorites/?url='+encodeURIComponent('<?php the_permalink() ?>')+'&title='+encodeURIComponent(document.title)+'&jumpback=2&noui=1','favit','width=640,height=600,left=50,top=50,toolbar=no,menubar=no,location=no,scrollbars=yes,status=yes,resizable=yes');void(0)"><img class="sharelink" title="添加到Live收藏夹" alt="Live收藏夹" src="<?php bloginfo('template_url'); ?>/sharelink/live.gif" width="16" height="16" /></a>
<!-- baidu -->
<a href="javascript:window.open('http://cang.baidu.com/do/add?it='+encodeURIComponent(document.title.substring(0,76))+'&iu='+encodeURIComponent('<?php the_permalink() ?>')+'&fr=ien#nw=1','_blank','scrollbars=no,width=600,height=450,left=50,top=50,status=no,resizable=yes'); void 0"><img class="sharelink" title="搜藏到百度搜藏" alt="百度搜藏" src="<?php bloginfo('template_url'); ?>/sharelink/baidu.gif" width="16" height="16" /></a>
<!-- QQ -->
<a href="javascript:window.open('http://shuqian.qq.com/post?from=3&title='+encodeURIComponent(document.title)+'&uri='+encodeURIComponent('<?php the_permalink() ?>')+'&jumpback=2&noui=1','favit','width=930,height=470,left=50,top=50,toolbar=no,menubar=no,location=no,scrollbars=yes,status=yes,resizable=yes');void(0)"><img class="sharelink" title="收藏到QQ书签" alt="QQ书签" src="<?php bloginfo('template_url'); ?>/sharelink/qq.ico" width="16" height="16" /></a>
<!-- renren -->
<a href="javascript:window.open('http://share.renren.com/share/buttonshare.do?link='+encodeURIComponent('<?php the_permalink() ?>')+'&title='+encodeURIComponent(document.title)+'&jumpback=2&noui=1','favit','width=600,height=400,left=50,top=50,toolbar=no,menubar=no,location=no,scrollbars=yes,status=yes,resizable=yes');void(0)"><img class="sharelink" title="分享到人人网" alt="人人网" src="<?php bloginfo('template_url'); ?>/sharelink/renren.ico" width="16" height="16" /></a>
<!-- kaixin -->
<a href="javascript:window.open('http://www.kaixin001.com/~repaste/repaste.php?rtitle='+encodeURIComponent(document.title)+'&url='+encodeURIComponent('<?php the_permalink() ?>')+'&jumpback=2&noui=1','favit','width=930,height=470,left=50,top=50,toolbar=no,menubar=no,location=no,scrollbars=yes,status=yes,resizable=yes');void(0)"><img class="sharelink" title="分享到开心网" alt="开心网" src="<?php bloginfo('template_url'); ?>/sharelink/kaixin.ico" width="16" height="16" /></a>
<!-- douban -->
<a href="javascript:window.open('http://www.douban.com/recommend/?url='+encodeURIComponent('<?php the_permalink() ?>')+'&title='+encodeURIComponent(document.title)+'&jumpback=2&noui=1','favit','width=600,height=400,left=50,top=50,toolbar=no,menubar=no,location=no,scrollbars=yes,status=yes,resizable=yes');void(0)"><img class="sharelink" title="推荐到豆瓣" alt="豆瓣" src="<?php bloginfo('template_url'); ?>/sharelink/douban.ico" width="16" height="16" /></a>
<!-- Sina -->
<a href="javascript:window.open('http://v.t.sina.com.cn/share/share.php?title='+encodeURIComponent(document.title)+'&url='+encodeURIComponent('<?php the_permalink() ?>')+'&jumpback=2&noui=1','favit','width=600,height=400,left=50,top=50,toolbar=no,menubar=no,location=no,scrollbars=yes,status=yes,resizable=yes');void(0)"><img class="sharelink" title="转发到新浪微博" alt="新浪微博" src="<?php bloginfo('template_url'); ?>/sharelink/sina.ico" width="16" height="16" /></a>
<!-- 腾讯微博 -->
<a href="javascript:window.open('http://v.t.qq.com/share/share.php?title='+encodeURIComponent(document.title)+'&url='+encodeURIComponent('<?php the_permalink() ?>')+'&jumpback=2&noui=1','favit','width=600,height=400,left=50,top=50,toolbar=no,menubar=no,location=no,scrollbars=yes,status=yes,resizable=yes');void(0)"><img class="sharelink" title="转发到腾讯微博" alt="腾讯微博" src="<?php bloginfo('template_url'); ?>/sharelink/tencent.ico" width="16" height="16" /></a>
<!-- Twitter -->
<a href="http://twitter.com/home?status=<?php the_title(); ?> « <?php bloginfo('name'); ?>+-+<?php the_permalink() ?>+" target="_blank"><img class="sharelink" title="转发到Twitter" alt="Twitter" src="<?php bloginfo('template_url'); ?>/sharelink/twitter.ico" width="16" height="16" /></a>
<!-- Google Buzz -->
<a href="javascript:window.open('http://www.google.com/buzz/post?url='+encodeURIComponent('<?php the_permalink() ?>')+'&jumpback=2&noui=1','favit','width=720,height=500,left=50,top=50,toolbar=no,menubar=no,location=no,scrollbars=yes,status=yes,resizable=yes');void(0)"><img class="sharelink" title="发布到Google Buzz" alt="Google Buzz" src="<?php bloginfo('template_url'); ?>/sharelink/buzz.png" width="16" height="15" /></a>
» 转载本站文章请注明,转载自:kisa747's world »《社会化分享按钮代码》

还是很全的@
@腾飞
我把感觉常用的都弄上面了
你还真能折腾啊。
不错啊。歇息啦
我不会这个 所以提个建议哈
两点不足
1、没有分享到QQ空间的按钮
2、新浪微博没有能够分享内容,而是单单的只有标题,跟官方给出的代码效果一致
建议参考下cnbeta的
这个正是我想要的 收藏了
撒打发
阿斯顿发生的
阿斯顿发生地方
ceshi
不好用啊
不错的功能,可惜没有代码讲解。
感觉代码都已经很简单了,所以就直接贴出来,也就懒的解释鸟~