我发现很多人的文章下面有“分享本文至某某某某”的链接,看着非常不错啊,我也知道一些做提供这种分享代码的网站,如:bshare.cn,jiathis.com等等,它们也都是非常不错的提供分享服务的网站。分享是互联网的核心价值所在,于是呢,我也来添加一下分享,不过我用手工添加自定义代码的方式,只分享至一部分网站。效果见本文下方。
于single.php的合适位置添加下面的代码(注意将全角引号换至半角!我也很无奈……):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | <font color="green"><strong>分享本文至:</strong></font> <a href="javascript:window.open('http://share.renren.com/share/buttonshare.do?title='+encodeURIComponent(document.title.substring(0,76))+'&link='+encodeURIComponent(location.href)+'&content=','_blank','scrollbars=no,width=600,height=450,left=75,top=20,status=no,resizable=yes');%20void%200"> <span style=" font-size: 12px; margin-left: 0; cursor:pointer;" title="分享到人人网"> <img src="http://www.ninthday.net/images/renren.gif" align="absMiddle" border="0"> 人人网 </span> </a> <a href="javascript:window.open('http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url='+encodeURIComponent(location.href)+'&rcontent=','_blank','scrollbars=no,width=600,height=450,left=75,top=20,status=no,resizable=yes');%20void%200"> <span style=" font-size: 12px; margin-left: 0; cursor:pointer;" title="分享到QQ空间"> <img src="http://www.ninthday.net/images/qzone.gif" align="absMiddle" border="0"> QQ空间 </span> </a> <a href="javascript:window.open('http://cang.baidu.com/do/add?it='+encodeURIComponent(document.title.substring(0,76))+'&iu='+encodeURIComponent(location.href)+'&rcontent=','_blank','scrollbars=no,width=600,height=450,left=75,top=20,status=no,resizable=yes');%20void%200"> <span style=" font-size: 12px; margin-left: 0; cursor:pointer;" title="分享到百度收藏"> <img src="http://www.ninthday.net/images/baidu.jpg" align="absMiddle" border="0"> 百度收藏 </span> </a> <a href="javascript:window.open('http://www.kaixin001.com/repaste/share.php?rtitle='+encodeURIComponent(document.title.substring(0,76))+'&rurl='+encodeURIComponent(location.href)+'&rcontent=','_blank','scrollbars=no,width=600,height=450,left=75,top=20,status=no,resizable=yes');%20void%200"> <span style=" font-size: 12px; margin-left: 0; cursor:pointer;" title="分享到开心网"> <img src="http://www.ninthday.net/images/kaixin.gif" align="absMiddle" border="0"> 开心网 </span> </a> <a href="javascript:window.open('http://v.t.sina.com.cn/share/share.php?title='+encodeURIComponent(document.title.substring(0,76))+'&url='+encodeURIComponent(location.href)+'&rcontent=','_blank','scrollbars=no,width=600,height=450,left=75,top=20,status=no,resizable=yes');%20void%200"> <span style=" font-size: 12px; margin-left: 0; cursor:pointer;" title="分享到新浪微薄"> <img src="http://www.ninthday.net/images/sina.gif" align="absMiddle" border="0"> 新浪微薄 </span> </a> <a href="javascript:window.open('http://www.google.com/bookmarks/mark?op=edit&output=popup&bkmk='+encodeURIComponent(document.location)+'&title='+encodeURIComponent(document.title),'bkmk_popup','_blank','scrollbars=no,width=600,height=450,left=75,top=20,status=no,resizable=yes');%20void%200"> <span style=" font-size: 12px; margin-left: 0; cursor:pointer;" title="分享到Google书签"> <img src="http://www.ninthday.net/images/google.gif" align="absMiddle" border="0"> Google书签 </span> </a> </div> |
将代码中的域名换成你的,然后下载对应的图片,添加上自己的样式就好了。
声明:本文采用 BY-NC-SA 协议进行授权 | 星期九
原创文章转载请注明:转自《非外挂代码为文章添加“分享至”》
这个留着收藏。以后用~
现在看到这代码依然晕
@志言,
,话说我好像已经司空见惯了,还幸亏以前有点HTML、JS和CSS的基础,现在PHP基本上也至少能看懂了。
全角半角,一不小心就给搞忘了。
@NFLJersey, 哦?我觉得这样是一劳永逸哦!
还是用插件的比较好,代码修改起了有点小麻烦
@WordPress啦, 还是用代码好,插件太拖速度了,我现在是深有体会……在我刚搬到拉斯维加斯的时候,都打不开网站了,后来大砍了几个插件,现在基本上页面加载时间在1秒以下。
Random Posts
Recent Posts
Recent Comments
By Plastic injection mould
By OOZJ
By Jusbe
By 互联网战
By 互联网战
By ixwebhosting
Blogroll
Categories
Tag Cloud
360 5800 Alexa C++ Chrome Cisco Dedecms Discuz Fcitx Fedora GFW Gravatar IE Linux Mobile ModelSim Music QT Quartus Shell Verilog VPN VPS Windows Wordpress XAMPP Xilinx xp 下载 垃圾评论 情感 手机 插件 星期九 注册 电子信息 程序设计 站长工具 缩略图 网络应用 考研 胡思乱想 西工大 视频 软件Meta