JavaScript,簡單的社交圈分享

來源:互聯網
上載者:User

標籤:shu   logs   text   one   ini   facebook   summary   .com   asc   

var share_templates = {    //qzone-param    url, title, desc, summary, site    qzone: ‘http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?‘,    //qq-param    url, title, desc, pics, source    qq: ‘http://connect.qq.com/widget/shareqq/index.html?‘,    //tencent-param    url, title, pic    tencent: ‘http://share.v.t.qq.com/index.php?c=share&a=index&‘,    //weibo-param    url, title, pic, appkey    weibo: ‘http://service.weibo.com/share/share.php?‘,    //douban-param    href, name, text, image    douban: ‘http://shuo.douban.com/!service/share?starid=0&aid=0&style=11&‘,    //linkedin-param    url, title, summary, source    linkedin: ‘http://www.linkedin.com/shareArticle?mini=true&ro=true&armin=armin&‘,    //facebook-param    u    facebook: ‘https://www.facebook.com/sharer/sharer.php?‘,    //twitter-param    text, url, via    twitter: ‘https://twitter.com/intent/tweet?‘,    //google-param    url    google: ‘https://plus.google.com/share?‘,    //line      url    line: ‘https://lineit.line.me/share/ui?‘};var share = function(sitename, param){  var paramString = share_templates[sitename] || share_templates.sitename;  if(paramString.trim() != ‘‘){    for (var key in param) {      if (param.hasOwnProperty(key)) {        paramString = paramString + key + ‘=‘ + encodeURIComponent(param[key]) + ‘&‘;      }    }    window.open(paramString,‘_blank‘);  }}

沒有的。github上有個不錯的項目 https://github.com/overtrue/share.js  就是有點太完美了,如果需求比較簡單,可以直接用上面的代碼。

順帶一提,分享串連時 param[key] 最好是Unicode編碼。

JavaScript,簡單的社交圈分享

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.