實現分享到QQ空間 新浪微博
參考網址:http://blog.csdn.net/zhangkaiadl/article/details/49782003
一、分享到QQ空間
只需添加個鏈接或者按鈕觸發這個事件即可使用
複製代碼:
$("#zone").click(function(){
var p = {
url:location.href, 分享的鏈接地址
showcount:'1',/*是否顯示分享總數,顯示:'1',不顯示:'0' */
desc:'',/*默認分享理由(可選)*/
summary:'我在【空間家】上找到一個好位置,地段好又划算,快來看看吧!',/*分享摘要(可選)*/
title:'<%$info.title%>',/*分享標題(可選)*/
site:'空間家',/*分享來源 如:騰訊網(可選)*/
pics:'__IMG__<%$info.img.0.url%>', /*分享圖片的路徑(可選)*/
style:'203',
width:98,
height:22
};
var s = [];
for(var i in p){
s.push(i + '=' + encodeURIComponent(p[i]||''));
}
window.open("http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?"+s.join('&'));
});
二、分享到微博
$('#blog').click(function(){
window.sharetitle = '<%$info.title%>';//標題
window.shareUrl = '__IMG__<%$info.img.0.url%>';//縮略圖
share();
});
function share(){
//d指的是window
(function(s,d,e){try{}catch(e){}var f='http://v.t.sina.com.cn/share/share.php?',u=d.location.href,p=['url=',e(u),'&title=',e(window.sharetitle),'&appkey=2924220432','&pic=',e(window.shareUrl)].join('');function a(){if(!window.open([f,p].join(''),'mb',['toolbar=0,status=0,resizable=1,width=620,height=450,left=',(s.width-620)/2,',top=',(s.height-450)/2].join('')))u.href=[f,p].join('');};if(/Firefox/.test(navigator.userAgent)){setTimeout(a,0)}else{a()}})(screen,document,encodeURIComponent);
}
三、分享鏈接到任何要想分享的地方
複製代碼:
<span class="date">
<!-- JiaThis Button BEGIN -->
<div class="jiathis_style_32x32">
<a class="jiathis_button_qzone"></a>
<a class="jiathis_button_tsina"></a>
<a class="jiathis_button_tqq"></a>
<!--<a class="jiathis_button_weixin"></a>-->
<a class="jiathis_button_feixin"></a>
<a class="jiathis_button_renren"></a>
<a class="jiathis_button_kaixin001"></a>
<a class="jiathis_button_hi"></a>
<a class="jiathis_button_tsohu"></a>
<a class="jiathis_button_douban"></a>
<a href="http://www.jiathis.com/share" class="jiathis jiathis_txt jtico jtico_jiathis" target="_blank"></a>
<a class="jiathis_counter_style"></a>
</div>
<script type="text/javascript" src="http://v3.jiathis.com/code_mini/jia.js?uid=1367461003302510" charset="utf-8"></script>
<!-- JiaThis Button END -->
</span>