社交网站和微博一键分享的代码

在社交网站和微博满天飞的时候,怎么让自己网页快速分享给好友?下面介绍开心网,人人网,新浪微博和腾讯微博一键分享的方法。

在HTML代码中加入如下

<a id="share2kaixin" href="#" target="_blank"><img src="images/p2_10.gif" width="16" height="28" alt="分享到开心网" /></a>
<a id="share2renren" href="#" target="_blank"><img src="images/p2_11.gif" width="16" height="28" alt="分享到人人网" /></a>
<a id="share2sina" href="#" target="_blank"><img src="images/p2_12.gif" width="16" height="28" alt="分享到新浪微博" /></a>
<a id="share2qq" href="#" target="_blank"><img src="images/p2_13.gif" width="16" height="28" alt="分享到腾讯微博" /></a>


在网页尾部加入如下Javascript代码

<script type="text/javascript">
var p_url = encodeURIComponent(top.location.href);
var p_title = encodeURIComponent(top.document.title);
var p_pic = "";
var share_kaixin = document.getElementById("share2kaixin");
var share_renren = document.getElementById("share2renren");
var share_sina = document.getElementById("share2sina");
var share_qq = document.getElementById("share2qq");
if(share_kaixin) share_kaixin.href = "http://www.kaixin001.com/repaste/share.php?rurl=" + p_url+"&rtitle="+p_title + "&rcontent=" + p_url;
if(share_renren) share_renren.href = "http://share.renren.com/share/buttonshare.do?link=" + p_url + "&title=" + p_title;
if(share_sina) share_sina.href = "http://v.t.sina.com.cn/share/share.php?url="+ p_url+"&title="+p_title+"&source={source}&sourceUrl={sourceUrl}&content=utf8&pic="+p_pic;
if(share_qq) share_qq.href = "http://v.t.qq.com/share/share.php?url="+p_url+"&title="+p_title+"&site={site}n&pic="+p_pic;
</script>

新浪微博的分享可以z指定{source}和{sourceUrl},腾讯微博可以指定{site},将这几个变量替换成你想要的内容即可。
这样你的网页就拥有一键分享功能。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值