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

编程入门 行业动态 更新时间:2024-10-09 15:22:37

js分享内容到QQ、QQ空间、<a href=https://www.elefans.com/category/jswz/34/1766670.html style=新浪博客"/>

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 = '.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 = '?';_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 = '.html?';_shareUrl += 'url=' + encodeURIComponent(_url||location.href);   //分享的链接_shareUrl += '&title=' + encodeURIComponent(_title||document.title);     //分享的标题_shareUrl += '&pics=' + encodeURIComponent(_pic);   //参数pics设置分享图片的路径,多张图片以"|"隔开,可选参数window.open(_shareUrl,'_blank');
})

 

更多推荐

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

本文发布于:2024-02-06 19:37:41,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1751202.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:新浪   内容   空间   博客   js

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!