js分享demo(js分享大全)

前端之家收集整理的这篇文章主要介绍了js分享demo(js分享大全)前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

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,resizable=1,status=0');

  27.  }

  28. //分享百度贴吧

  29.  function shareToTieba(event){

  30.       event.preventDefault();

  31.      

  32.      var _shareUrl = 'http://tieba.baidu.com/f/commit/share/openShareApi?';

  33.      _shareUrl += 'title=' + encodeURIComponent(_title||document.title);  //分享标题

  34.      _shareUrl += '&url=' + encodeURIComponent(_url||document.location);  //分享链接

  35.      _shareUrl += '&pic=' + encodeURIComponent(_pic||'');    //分享图片

  36.      window.open(_shareUrl,status=0');

  37.  }

  38.  

  39.  //分享到豆瓣

  40.  function shareToDouban(event){

  41.      event.preventDefault();

  42.  

  43.      var _shareUrl = 'http://shuo.douban.com/!service/share?';

  44.       _shareUrl += 'href=' + encodeURIComponent(_url||location.href);    //分享链接

  45.      _shareUrl += '&name=' + encodeURIComponent(_title||document.title);    //分享标题

  46.      _shareUrl += '&image=' + encodeURIComponent(_pic||'');    //分享图片

  47.      window.open(_shareUrl,status=0');

  48.  }

  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,status=0');

  61.  }

  62.  

  63.  //分享到人人网

  64.  function shareToRenren(event){

  65.     event.preventDefault();

  66.      

  67.      var _shareUrl = 'http://share.renren.com/share/buttonshare.do?';

  68.      _shareUrl += 'link=' + encodeURIComponent(_url||location.href);   //分享链接

  69.      _shareUrl += '&title=' + encodeURIComponent(_title||document.title);     //分享标题

  70.      window.open(_shareUrl,status=0');

  71.  }

  72.  

  73.  //分享到开心网

  74.  function shareToKaixin(event){

  75.      event.preventDefault();

  76.      

  77.      var _shareUrl = 'http://www.kaixin001.com/rest/records.PHP?';

  78.      _shareUrl += 'url=' + encodeURIComponent(_url||location.href);    //分享链接

  79.      _shareUrl += '&content=' + encodeURIComponent('分享文字');    //需要分享文字,当文字为空时,自动抓取分享网址的title

  80.      _shareUrl += '&pic=' + encodeURIComponent(_pic||'');     //分享图片,多个使用半角逗号分隔

  81.      _shareUrl += '&showcount=0';    //是否显示分享数,显示:'1',不显示:'0'

  82.       _shareUrl += '&style=11';      //显示的样式,必选参数

  83.      _shareUrl += '&aid=' + encodeURIComponent(_site||'');    //显示分享来源

  84.      window.open(_shareUrl,status=0');

  85.  }

  86.  

  87.  function shareToKaixin2(event){

  88.      event.preventDefault();

  89.      

  90.      var _shareUrl = 'http://www.kaixin001.com/repaste/share.PHP?';

  91.      _shareUrl += 'rtitle=' + encodeURIComponent(_title||document.title);   //分享标题

  92.      window.open(_shareUrl,status=0');

  93.  }

  94.  

  95.  //分享到facebook

  96.  function shareToFacebook(event){

  97.      event.preventDefault();

  98.      

  99.      var _shareUrl = 'http://www.facebook.com/sharer/sharer.PHP?';

  100.      _shareUrl += 'u=' + encodeURIComponent(_url||location.href);    //分享链接

  101.      _shareUrl += '&t=' + encodeURIComponent(_title||document.title);    //分享标题

  102.      window.open(_shareUrl,status=0');

  103.  }

  104.  

  105.  //分享到Twitter

  106.  function shareToTwitter(event){

  107.      event.preventDefault();

  108.      

  109.      var _shareUrl = 'http://twitter.com/intent/tweet?';

  110.      _shareUrl += 'url=' + encodeURIComponent(_url||location.href);    //分享链接

  111.      _shareUrl += '&text=' + encodeURIComponent(_title||document.title);    //分享标题

  112.      window.open(_shareUrl,status=0');

  113.  }

  114.  </script>

猜你在找的jQuery相关文章