1.首先说明的是,pc端微信分享只能通过二维码来分享。

2.下面是js代码。

  1. //分享到新浪微博
  2. function shareToSinaWB(event){
  3. event.preventDefault();
  4. var _shareUrl = 'http://v.t.sina.com.cn/share/share.php?&appkey=895033136'; //真实的appkey,必选参数
  5. _shareUrl += '&url='+ encodeURIComponent(_url||document.location); //参数url设置分享的内容链接|默认当前页location,可选参数
  6. _shareUrl += '&title=' + encodeURIComponent(_title||document.title); //参数title设置分享的标题|默认当前页标题,可选参数
  7. _shareUrl += '&source=' + encodeURIComponent(_source||'');
  8. _shareUrl += '&sourceUrl=' + encodeURIComponent(_sourceUrl||'');
  9. _shareUrl += '&content=' + 'utf-8'; //参数content设置页面编码gb2312|utf-8,可选参数
  10. _shareUrl += '&pic=' + encodeURIComponent(_pic||''); //参数pic设置图片链接|默认为空,可选参数
  11. window.open(_shareUrl,'_blank','width='+_width+',height='+_height+',top='+_top+',left='+_left+',toolbar=no,menubar=no,scrollbars=no, resizable=1,location=no,status=0');
  12. }
  13.  
  14. //分享到QQ空间
  15. function shareToQzone(event){
  16. event.preventDefault();
  17.  
  18. var _shareUrl = 'http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?';
  19. _shareUrl += 'url=' + encodeURIComponent(_url||document.location); //参数url设置分享的内容链接|默认当前页location
  20. _shareUrl += '&showcount=' + _showcount||0; //参数showcount是否显示分享总数,显示:'1',不显示:'0',默认不显示
  21. _shareUrl += '&desc=' + encodeURIComponent(_desc||'分享的描述'); //参数desc设置分享的描述,可选参数
  22. _shareUrl += '&summary=' + encodeURIComponent(_summary||'分享摘要'); //参数summary设置分享摘要,可选参数
  23. _shareUrl += '&title=' + encodeURIComponent(_title||document.title); //参数title设置分享标题,可选参数
  24. _shareUrl += '&site=' + encodeURIComponent(_site||''); //参数site设置分享来源,可选参数
  25. _shareUrl += '&pics=' + encodeURIComponent(_pic||''); //参数pics设置分享图片的路径,多张图片以"|"隔开,可选参数
  26. window.open(_shareUrl,'_blank','width='+_width+',height='+_height+',top='+_top+',left='+_left+',toolbar=no,menubar=no,scrollbars=no,resizable=1,location=no,status=0');
  27. }
  28.  
  29. //分享到百度贴吧
  30. function shareToTieba(event){
  31. event.preventDefault();
  32.  
  33. var _shareUrl = 'http://tieba.baidu.com/f/commit/share/openShareApi?';
  34. _shareUrl += 'title=' + encodeURIComponent(_title||document.title); //分享的标题
  35. _shareUrl += '&url=' + encodeURIComponent(_url||document.location); //分享的链接
  36. _shareUrl += '&pic=' + encodeURIComponent(_pic||''); //分享的图片
  37. window.open(_shareUrl,'_blank','width='+_width+',height='+_height+',left='+_left+',top='+_top+',toolbar=no,menubar=no,scrollbars=no,resizable=1,location=no,status=0');
  38. }
  39.  
  40. //分享到豆瓣
  41. function shareToDouban(event){
  42. event.preventDefault();
  43.  
  44. var _shareUrl = 'http://shuo.douban.com/!service/share?';
  45. _shareUrl += 'href=' + encodeURIComponent(_url||location.href); //分享的链接
  46. _shareUrl += '&name=' + encodeURIComponent(_title||document.title); //分享的标题
  47. _shareUrl += '&image=' + encodeURIComponent(_pic||''); //分享的图片
  48. window.open(_shareUrl,'_blank','width='+_width+',height='+_height+',left='+_left+',top='+_top+',toolbar=no,menubar=no,scrollbars=no,resizable=1,location=no,status=0');
  49. }
  50. //分享到腾讯微博
  51. function shareToQQwb(event){
  52. event.preventDefault();
  53.  
  54. var _shareUrl = 'http://v.t.qq.com/share/share.php?';
  55. _shareUrl += 'title=' + encodeURIComponent(_title||document.title); //分享的标题
  56. _shareUrl += '&url=' + encodeURIComponent(_url||location.href); //分享的链接
  57. _shareUrl += '&appkey=5bd32d6f1dff4725ba40338b233ff155'; //在腾迅微博平台创建应用获取微博AppKey
  58. _shareUrl += '&site=' + encodeURIComponent(_site||''); //分享来源
  59. _shareUrl += '&pic=' + encodeURIComponent(_pic||''); //分享的图片,如果是多张图片,则定义var _pic='图片url1|图片url2|图片url3....'
  60. window.open(_shareUrl,'_blank','width='+_width+',height='+_height+',left='+_left+',top='+_top+',toolbar=no,menubar=no,scrollbars=no,resizable=1,location=no,status=0');
  61. }
  62.  
  63. //分享到开心网
  64. function shareToKaixin(event){
  65. event.preventDefault();
  66.  
  67. var _shareUrl = 'http://www.kaixin001.com/rest/records.php?';
  68. _shareUrl += 'url=' + encodeURIComponent(_url||location.href); //分享的链接
  69. _shareUrl += '&content=' + encodeURIComponent('分享的文字'); //需要分享的文字,当文字为空时,自动抓取分享网址的title
  70. _shareUrl += '&pic=' + encodeURIComponent(_pic||''); //分享的图片,多个使用半角逗号分隔
  71. _shareUrl += '&showcount=0'; //是否显示分享数,显示:'1',不显示:'0'
  72. _shareUrl += '&style=11'; //显示的样式,必选参数
  73. _shareUrl += '&aid=' + encodeURIComponent(_site||''); //显示分享来源
  74. window.open(_shareUrl,'_blank','width='+_width+',height='+_height+',left='+_left+',top='+_top+',toolbar=no,menubar=no,scrollbars=no,resizable=1,location=no,status=0');
  75. }
  76.  
  77. function shareToKaixin2(event){
  78. event.preventDefault();
  79.  
  80. var _shareUrl = 'http://www.kaixin001.com/repaste/share.php?';
  81. _shareUrl += 'rtitle=' + encodeURIComponent(_title||document.title); //分享的标题
  82. window.open(_shareUrl,'_blank','width='+_width+',height='+_height+',left='+_left+',top='+_top+',toolbar=no,menubar=no,scrollbars=no,resizable=1,location=no,status=0');
  83. }
  84.  
  85. //分享到facebook
  86. function shareToFacebook(event){
  87. event.preventDefault();
  88.  
  89. var _shareUrl = 'http://www.facebook.com/sharer/sharer.php?';
  90. _shareUrl += 'u=' + encodeURIComponent(_url||location.href); //分享的链接
  91. _shareUrl += '&t=' + encodeURIComponent(_title||document.title); //分享的标题
  92. window.open(_shareUrl,'_blank','width='+_width+',height='+_height+',left='+_left+',top='+_top+',toolbar=no,menubar=no,scrollbars=no,resizable=1,location=no,status=0');
  93. }
  94. //分享到facebook
  95. function shareToFacebook(event){
  96. event.preventDefault();
  97.  
  98. var _shareUrl = 'http://www.facebook.com/sharer/sharer.php?';
  99. _shareUrl += 'u=' + encodeURIComponent(_url||location.href); //分享的链接
  100. _shareUrl += '&t=' + encodeURIComponent(_title||document.title); //分享的标题
  101. window.open(_shareUrl,'_blank','width='+_width+',height='+_height+',left='+_left+',top='+_top+',toolbar=no,menubar=no,scrollbars=no,resizable=1,location=no,status=0');
  102. }
  103.  
  104. //分享到Twitter
  105. function shareToTwitter(event){
  106. event.preventDefault();
  107.  
  108. var _shareUrl = 'http://twitter.com/intent/tweet?';
  109. _shareUrl += 'url=' + encodeURIComponent(_url||location.href); //分享的链接
  110. _shareUrl += '&text=' + encodeURIComponent(_title||document.title); //分享的标题
  111. window.open(_shareUrl,'_blank','width='+_width+',height='+_height+',left='+_left+',top='+_top+',toolbar=no,menubar=no,scrollbars=no,resizable=1,location=no,status=0');
  112. }

  

网页分享到微信、微博、QQ空间、百度贴吧等的更多相关文章

  1. 《社交红利》读书总结--如何从微信微博QQ空间等社交网络带走海量用户、流量与收入

    <社交红利--如何从微信微博QQ空间等社交网络带走海量用户.流量与收入>--徐志斌 著 <社交红利>这本书2013年9月才上市,卖的非常火. 我最初是在公司内部的期刊上,看到有 ...

  2. 分享到微信微博空间等第三方平台的JS代码

    分享功能有利于传播更多优质的内容,所以在web项目中也是比较常用的.今天就抽空整理下常用的分享平台的JS代码.这些代码可以在对应平台的官方网站上生成,官网上对分享内容的参数也有详尽说明.这里只对常用的 ...

  3. App分享之微信微博等各个社交平台的分享授权规则和常见问题

    一.新浪微博分享规则 新浪微博支持分享类型: 应用内分享也就是网页分享支持: 文字,文字+图片,要分享链接需要链接添加在text里分享 客户端分享支持:文字,图片,文字+图片,图片+文字+链接 参数说 ...

  4. 利用LibreOffice与ImageMagick将网页分享至微信

    现在越来越多的内容分享都是在微信上进行了.然而,若想将电脑浏览器中看到的感兴趣的网页分享至微信,则只能以纯文本的方式粘贴超级链接,而不能直接拷贝图文混排的HTML.因此,我想到不妨借助LibreOff ...

  5. 移动端分享到微信和QQ

    关于在H5页面实现分享到微信和QQ,当初做的时候由于没有做过这方面的功能,也查了很多资料,找了很多插件,试了很多方法,大部分的都是点击后出现一个二维码,这不 符合我的需求,所以在网上找了一个 nati ...

  6. 分享微博,qq空间,微信

    <div class="share_class" ><div class="bdsharebuttonbox">    <a hr ...

  7. 网站文章分享到微博,微信、qq空间--举例用织梦

    有对应接口的,传递参数过去就行了,注意下面的{..},需要替换为你的内容,看参数名称你应该知道是什么东东 新浪地址接口http://service.weibo.com/share/share.php? ...

  8. 自己动手写js分享插件 [支持https] (QQ空间,微信,新浪微博。。。)

    转载:https://blog.csdn.net/libin_1/article/details/52424340 废话不多说,传送门:http://download.csdn.net/detail/ ...

  9. 分享至微信、QQ、微博、复制链接

    var share = { "tit": '您的朋友分享了文章', "desc": '分享来自百度文库,包含...', "pic": 'ht ...

随机推荐

  1. spark-scala-java实现wordcount

    引入:spark-scala-java实现wordcount 1.spark-scala实现wordcount package com.cw.scala.spark import org.apache ...

  2. 经验:什么影响了数据库查询速度、什么影响了MySQL性能 (转)

    一.什么影响了数据库查询速度 1.1 影响数据库查询速度的四个因素 1.2 风险分析 QPS:Queries Per Second意思是“每秒查询率”,是一台服务器每秒能够相应的查询次数,是对一个特定 ...

  3. INPUT和CONSTRUCT指令——范例报表查询,作用让用户输入数据,自动生成SQL的WHERE条件,带开窗查询

    INPUT指令 说明:1. 当程序执行到INPUT指令时,会将控制权交给用户,让用户输入数据.2. 用户输入完字段的数据,会将数据回传给程序中的变量接收.3. 只要执行到INPUT的指令,程序会将每个 ...

  4. CentOS 修改/etc/resolv.conf 重启network后又恢复到原来的状态?

    问题描述:CentOS 修改/etc/resolv.conf 执行service network restart后,/etc/resolv.conf又恢复到原来的状态 解决方法:/etc/resolv ...

  5. 深入理解计算机系统 第十章 系统级I/O 第二遍

    了解 Unix I/O 的好处 了解 Unix I/O 将帮助我们理解其他的系统概念 I/O 是系统操作不可或缺的一部分,因此,我们经常遇到 I/O 和其他系统概念之间的循环依赖.例如,I/O 在进程 ...

  6. 进阶Java编程(11)ClassLoader类加载器【待完成】

    1,ClassLoader类加载器简介 在Java里面提供一个系统的环境变量:ClassPath,这个属性的作用主要是在JVM进程启动的时候进行类加载路径的定义,在JVM里面可以根据类加载器而后进行指 ...

  7. windows安装npm教程

    1.在使用之前,先类掌握3个东西,明白它们是用来干什么的: npm:  nodejs 下的包管理器. webpack: 它主要用途是通过CommonJS 的语法把所有浏览器端需要发布的静态资源作相应的 ...

  8. 无障碍开发(六)之ARIA在HTML中的使用规则

    ARIA使用规则一 如果你使用的元素( HTML5 )具有语义化,应该使用这些元素,而不应该重新定义一个添加ARIA的角色.状态或属性的元素. 浏览器的语义化标签已经默认隐含ARIA语义,像nav,a ...

  9. python 的面试题总汇

    函数作用域; LEGB : L>E>G>B L : local函数内部作用域 E : enclosing函数内部与内嵌函数之间 G : global全局作用域 B : build-i ...

  10. WebStrom 中文显示异常中文变样乱码

    问题描述 WebStorm 编辑文件时中文显示异常,大小不一 菜单栏字体需要更换 解决方法 修改编辑器字体 菜单栏默认字体取消 设置效果 编辑文件时中英文显示 菜单栏 其他相关 关于编码格式,这里未做 ...