新浪博客"/>
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空间、新浪博客
发布评论