网页分享到微信、微博、QQ等
来源:互联网 发布:js给div赋值 编辑:程序博客网 时间:2024/06/05 00:38
首先要说明的是,pc端微信分享只能通过二维码来分享。
部分代码如下:
//分享到新浪微博 function shareToSinaWB(event){ event.preventDefault(); var _shareUrl = 'http://v.t.sina.com.cn/share/share.php?&appkey=895033136'; //真实的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','width='+_width+',height='+_height+',top='+_top+',left='+_left+',toolbar=no,menubar=no,scrollbars=no, resizable=1,location=no,status=0'); } //分享到QQ空间 function shareToQzone(event){ event.preventDefault(); var _shareUrl = 'http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?'; _shareUrl += 'url=' + encodeURIComponent(_url||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','width='+_width+',height='+_height+',top='+_top+',left='+_left+',toolbar=no,menubar=no,scrollbars=no,resizable=1,location=no,status=0'); } //分享到百度贴吧 function shareToTieba(event){ event.preventDefault(); var _shareUrl = 'http://tieba.baidu.com/f/commit/share/openShareApi?'; _shareUrl += 'title=' + encodeURIComponent(_title||document.title); //分享的标题 _shareUrl += '&url=' + encodeURIComponent(_url||document.location); //分享的链接 _shareUrl += '&pic=' + encodeURIComponent(_pic||''); //分享的图片 window.open(_shareUrl,'_blank','width='+_width+',height='+_height+',left='+_left+',top='+_top+',toolbar=no,menubar=no,scrollbars=no,resizable=1,location=no,status=0'); } //分享到豆瓣 function shareToDouban(event){ event.preventDefault(); var _shareUrl = 'http://shuo.douban.com/!service/share?'; _shareUrl += 'href=' + encodeURIComponent(_url||location.href); //分享的链接 _shareUrl += '&name=' + encodeURIComponent(_title||document.title); //分享的标题 _shareUrl += '&image=' + encodeURIComponent(_pic||''); //分享的图片 window.open(_shareUrl,'_blank','width='+_width+',height='+_height+',left='+_left+',top='+_top+',toolbar=no,menubar=no,scrollbars=no,resizable=1,location=no,status=0'); } //分享到腾讯微博 function shareToQQwb(event){ event.preventDefault(); var _shareUrl = 'http://v.t.qq.com/share/share.php?'; _shareUrl += 'title=' + encodeURIComponent(_title||document.title); //分享的标题 _shareUrl += '&url=' + encodeURIComponent(_url||location.href); //分享的链接 _shareUrl += '&appkey=5bd32d6f1dff4725ba40338b233ff155'; //在腾迅微博平台创建应用获取微博AppKey _shareUrl += '&site=' + encodeURIComponent(_site||''); //分享来源 _shareUrl += '&pic=' + encodeURIComponent(_pic||''); //分享的图片,如果是多张图片,则定义var _pic='图片url1|图片url2|图片url3....' window.open(_shareUrl,'_blank','width='+_width+',height='+_height+',left='+_left+',top='+_top+',toolbar=no,menubar=no,scrollbars=no,resizable=1,location=no,status=0'); } //分享到人人网 function shareToRenren(event){ event.preventDefault(); var _shareUrl = 'http://share.renren.com/share/buttonshare.do?'; _shareUrl += 'link=' + encodeURIComponent(_url||location.href); //分享的链接 _shareUrl += '&title=' + encodeURIComponent(_title||document.title); //分享的标题 window.open(_shareUrl,'_blank','width='+_width+',height='+_height+',left='+_left+',top='+_top+',toolbar=no,menubar=no,scrollbars=no,resizable=1,location=no,status=0'); } //分享到开心网 function shareToKaixin(event){ event.preventDefault(); var _shareUrl = 'http://www.kaixin001.com/rest/records.php?'; _shareUrl += 'url=' + encodeURIComponent(_url||location.href); //分享的链接 _shareUrl += '&content=' + encodeURIComponent('分享的文字'); //需要分享的文字,当文字为空时,自动抓取分享网址的title _shareUrl += '&pic=' + encodeURIComponent(_pic||''); //分享的图片,多个使用半角逗号分隔 _shareUrl += '&showcount=0'; //是否显示分享数,显示:'1',不显示:'0' _shareUrl += '&style=11'; //显示的样式,必选参数 _shareUrl += '&aid=' + encodeURIComponent(_site||''); //显示分享来源 window.open(_shareUrl,'_blank','width='+_width+',height='+_height+',left='+_left+',top='+_top+',toolbar=no,menubar=no,scrollbars=no,resizable=1,location=no,status=0'); } function shareToKaixin2(event){ event.preventDefault(); var _shareUrl = 'http://www.kaixin001.com/repaste/share.php?'; _shareUrl += 'rtitle=' + encodeURIComponent(_title||document.title); //分享的标题 window.open(_shareUrl,'_blank','width='+_width+',height='+_height+',left='+_left+',top='+_top+',toolbar=no,menubar=no,scrollbars=no,resizable=1,location=no,status=0'); } //分享到facebook function shareToFacebook(event){ event.preventDefault(); var _shareUrl = 'http://www.facebook.com/sharer/sharer.php?'; _shareUrl += 'u=' + encodeURIComponent(_url||location.href); //分享的链接 _shareUrl += '&t=' + encodeURIComponent(_title||document.title); //分享的标题 window.open(_shareUrl,'_blank','width='+_width+',height='+_height+',left='+_left+',top='+_top+',toolbar=no,menubar=no,scrollbars=no,resizable=1,location=no,status=0'); } //分享到facebook function shareToFacebook(event){ event.preventDefault(); var _shareUrl = 'http://www.facebook.com/sharer/sharer.php?'; _shareUrl += 'u=' + encodeURIComponent(_url||location.href); //分享的链接 _shareUrl += '&t=' + encodeURIComponent(_title||document.title); //分享的标题 window.open(_shareUrl,'_blank','width='+_width+',height='+_height+',left='+_left+',top='+_top+',toolbar=no,menubar=no,scrollbars=no,resizable=1,location=no,status=0'); } //分享到Twitter function shareToTwitter(event){ event.preventDefault(); var _shareUrl = 'http://twitter.com/intent/tweet?'; _shareUrl += 'url=' + encodeURIComponent(_url||location.href); //分享的链接 _shareUrl += '&text=' + encodeURIComponent(_title||document.title); //分享的标题 window.open(_shareUrl,'_blank','width='+_width+',height='+_height+',left='+_left+',top='+_top+',toolbar=no,menubar=no,scrollbars=no,resizable=1,location=no,status=0'); }
显示地址:http://sabrinatian.github.io/webpage-sharing/share.html
ps:因为没加二维码的图片,因此代码显示网页中的微信分享下没有图片
完整代码下载地址:https://github.com/SabrinaTian/webpage-sharing/tree/gh-pages
0 0
- 网页分享到微信、微博、QQ等
- 网页分享到微信、微博、QQ等
- 网页中实现"分享至微博、QQ空间等"代码示例
- HTML代码 网页设置 QQ空间等分享
- 网页中实现"分享至微博、QQ空间等"代码
- web网页,移动端h5页面添加微信分享,qq分享等功能
- Android分享功能,微博、QQ、QQ空间等社交平台分享之入门与进阶
- bShare分享-分享到微信、微博、QQ
- QQ图片分享和网页分享
- 分享到微信,qq空间,微博
- 友盟6.0SDK分享到微信,QQ,新浪等平台
- WEB页面实现QQ,微博,等分享链接
- 手机QQ内置网页分享API
- mod微信,qq等分享
- 分享到qq空间,微博等
- Android 分享到qq和qq空间中的网页
- Android 关于QQ分享,微信分享网页
- android ShareSDK分享,QQ,微信,新浪等分享
- C++函数指针、函数对象与C++11 function对象对比分析
- android studio 使用github完整保存
- [BZOJ1854][Scoi2010]游戏(二分图)
- TCP/IP详解(二)---数据链路层、MTU
- Ubuntu下安装NTP服务器
- 网页分享到微信、微博、QQ等
- Hadoop Join
- find_xargs_exec
- python main函数中变量默认为global variable & SIGKILL SIGSTOP 无法捕获
- 合并两个有序的链表
- Spark定制版2:通过案例对SparkStreaming透彻理解三板斧之二
- 初探Java
- vueJs源码解读0-1
- 第8章 线程的同步