非外挂代码为文章添加“分享至”

Posted by Harid九月 - 12 - 2010 Leave comments   60 views 

我发现很多人的文章下面有“分享本文至某某某某”的链接,看着非常不错啊,我也知道一些做提供这种分享代码的网站,如: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))+'&amp;link='+encodeURIComponent(location.href)+'&amp;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">&nbsp;人人网
		</span>
	</a>
	<a href="javascript:window.open('http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url='+encodeURIComponent(location.href)+'&amp;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">&nbsp;QQ空间
		</span>
	</a>
	<a href="javascript:window.open('http://cang.baidu.com/do/add?it='+encodeURIComponent(document.title.substring(0,76))+'&amp;iu='+encodeURIComponent(location.href)+'&amp;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">&nbsp;百度收藏
		</span>
	</a>
	<a href="javascript:window.open('http://www.kaixin001.com/repaste/share.php?rtitle='+encodeURIComponent(document.title.substring(0,76))+'&amp;rurl='+encodeURIComponent(location.href)+'&amp;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">&nbsp;开心网
		</span>
	</a>
	<a href="javascript:window.open('http://v.t.sina.com.cn/share/share.php?title='+encodeURIComponent(document.title.substring(0,76))+'&amp;url='+encodeURIComponent(location.href)+'&amp;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">&nbsp;新浪微薄
		</span>
	</a>
	<a href="javascript:window.open('http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk='+encodeURIComponent(document.location)+'&amp;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">&nbsp;Google书签
		</span>
	</a>
</div>

将代码中的域名换成你的,然后下载对应的图片,添加上自己的样式就好了。

   声明:本文采用 BY-NC-SA 协议进行授权 | 星期九
   原创文章转载请注明:转自《非外挂代码为文章添加“分享至”

分享本文: 腾讯微博 QQ空间 人人网 百度空间 开心网 新浪微博 Google Reader 豆瓣
Comments(7) Leave comments
  1. Gravatar
    小黄 Google Chrome Google Chrome 6.0.472.62 Windows Windows XP

    这个留着收藏。以后用~

  2. Gravatar
    志言 Google Chrome Google Chrome 6.0.472.59 Windows Windows XP

    现在看到这代码依然晕

    • Gravatar Harid  @  九月 20th, 2010 at 22:35 replied.  | #3

      @志言, :smile: ,话说我好像已经司空见惯了,还幸亏以前有点HTML、JS和CSS的基础,现在PHP基本上也至少能看懂了。

  3. Gravatar
    monclerjacket Mozilla Firefox Mozilla Firefox 3.6.9 Windows Windows XP

    全角半角,一不小心就给搞忘了。

  4. Gravatar
    Harid Mozilla Firefox Mozilla Firefox 3.6.7 Fedora Linux Fedora Linux

    @NFLJersey, 哦?我觉得这样是一劳永逸哦!

  5. Gravatar
    WordPress啦 360 Browser 360 Browser SE Windows Windows XP

    还是用插件的比较好,代码修改起了有点小麻烦

    • Gravatar Harid  @  九月 13th, 2010 at 20:34 replied.

      @WordPress啦, 还是用代码好,插件太拖速度了,我现在是深有体会……在我刚搬到拉斯维加斯的时候,都打不开网站了,后来大砍了几个插件,现在基本上页面加载时间在1秒以下。

9 + 4 =  (required)
 疑问 鼓掌 难过 呲牙 强 微笑 快哭了 坏笑 汗 奋斗 撇嘴 OK 偷笑 委屈 尴尬 傲慢 握手 玫瑰 胜利 大哭 抱拳
启用云输入法:      

NOTICE1: You should type some Chinese word (like “你好”) in your comment to pass the spam-check, thanks for your patience!

NOTICE2: 请申请gravatar头像(http://en.gravatar.com),木有头像的会显示为“小怪物”头像,将难以通过审核!

NOTICE3: 如果您能消除一下评论框旁边的邻居的寂寞的话,Harid将不胜感激,你懂的!^_^