js分享内容到QQ、QQ空间、新浪博客

js分享内容到QQ、QQ空间、新浪博客都是直接调用api的,很简单,不多说,直接上代码:

var _title,_source,_sourceUrl,_pic,_showcount,_desc,_summary,_site;

//  新浪微博分享
$('.xlwb-share').on('click',function(event){
       event.preventDefault();
       $('.panle-share').hide()
       var _shareUrl = 'http://v.t.sina.com.cn/share/share.php?title="123"';     //真实的appkey,必选参数
       _shareUrl += '&url='+ encodeURIComponent(_url||document.location);     //参数url设置分享的内容链接|默认当前页location,可选参数
       _shareUrl += '&title=' + encodeURIComponent(_title||document.title);    //参数title设置分享的标题|默认当前页标题,可选参数
       _shareUrl += '&source=' + encodeURIComponent(_source||'');
       _shareUrl += '&sourceUrl=' + encodeURIComponent(_sourceUrl||'');
       _shareUrl += '&content=' + 'utf-8';   //参数content设置页面编码gb2312|utf-8,可选参数
       _shareUrl += '&pic=' + encodeURIComponent(_pic);  //参数pic设置图片链接|默认为空,可选参数
       window.open(_shareUrl,'_blank');
})

//  QQ空间分享
$('.QQ-zong-share').on('click',function(event){
     event.preventDefault();
     $('.panle-share').hide()
     var _shareUrl = 'http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?';
     _shareUrl += 'url=' + encodeURIComponent(_urls||document.location);   //参数url设置分享的内容链接|默认当前页location
     _shareUrl += '&showcount=' + _showcount||0;      //参数showcount是否显示分享总数,显示:'1',不显示:'0',默认不显示
     _shareUrl += '&desc=' + encodeURIComponent(_desc||'分享的描述');    //参数desc设置分享的描述,可选参数
     _shareUrl += '&summary=' + encodeURIComponent(_summary||'分享摘要');    //参数summary设置分享摘要,可选参数
     _shareUrl += '&title=' + encodeURIComponent(_title||document.title);    //参数title设置分享标题,可选参数
     _shareUrl += '&site=' + encodeURIComponent(_site||'');   //参数site设置分享来源,可选参数
     _shareUrl += '&pics=' + encodeURIComponent(_pic);   //参数pics设置分享图片的路径,多张图片以"|"隔开,可选参数
     window.open(_shareUrl,'_blank');
})

//  QQ好友分享
$('.QQ-friend-share').on('click',function(event){
      event.preventDefault();
      $('.panle-share').hide()
      var _shareUrl = 'https://connect.qq.com/widget/shareqq/iframe_index.html?';
      _shareUrl += 'url=' + encodeURIComponent(_url||location.href);   //分享的链接
      _shareUrl += '&title=' + encodeURIComponent(_title||document.title);     //分享的标题
      _shareUrl += '&pics=' + encodeURIComponent(_pic);   //参数pics设置分享图片的路径,多张图片以"|"隔开,可选参数
      window.open(_shareUrl,'_blank');
})

 

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值