• 7个好用的社交分享按钮代码片段


    社交分享按钮几乎成了网页的标配。我在这里分享一些我从网上收集的社交分享按钮的代码片段。我相信,一切取自网络的,必须回馈给网络。

    share your content

    Twitter

    <!-- Place this tag where you want the share button to render. -->
    <a href="https://twitter.com/share" class="twitter-share-button">Tweet</a>
    
    <!-- Place this tag after the last share tag -->
    <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
    

    Google Plus

    <!-- Place this tag where you want the share button to render. -->
    
    
    <div class="g-plus" data-action="share"></div>
    
    
    
    <!-- Place this tag after the last share tag. -->
    
    
    <script type="text/javascript">
      (function() {
        var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
        po.src = 'https://apis.google.com/js/plusone.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
      })();
    </script>
    
    
    

    Facebook Like

    <!--Place the code for your plugin wherever you want the plugin to appear on your page. -->
    
    
    <div class="fb-like" data-href="http://developers.facebook.com/docs/reference/plugins/like" data-send="true" data-width="450" data-show-faces="true"></div>
    
    
    
    <!-- Include the JavaScript SDK on your page once, ideally right after the opening <body> tag. -->
    
    
    <div id="fb-root"></div>
    
    
    <script>(function(d, s, id) {
      var js, fjs = d.getElementsByTagName(s)[0];
      if (d.getElementById(id)) return;
      js = d.createElement(s); js.id = id;
      js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
      fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));</script>
    

    Hacker News

    <!-- Place this tag where you want the share button to render. -->
    <a href="http://news.ycombinator.com/submit" class="hn-share-button">Vote on HN</a>
    
    <!-- Place this tag after the last share tag -->
    
    
    <script>
        (function(d, t) {
            var g = d.createElement(t),
                s = d.getElementsByTagName(t)[0];
            g.src = '//hnbutton.appspot.com/static/hn.min.js';
            s.parentNode.insertBefore(g, s);
        }(document, 'script'));
    </script>
    
    
    

    Reddit

    a href="http://www.reddit.com/submit" onclick="window.location = 'http://www.reddit.com/submit?url=' + encodeURIComponent(window.location); return false"> <img src="http://www.reddit.com/static/spreddit7.gif" alt="submit to reddit" border="0" /> </a>
    

    如果你希望带上Reddit数目:

    <script type="text/javascript" src="http://www.reddit.com/buttonlite.js?i=1"></script>
    

    Kippt

    我喜欢在Kippt上收藏站点。给同样喜欢Kippt的用户:

    <a href="https://kippt.com/save" class="kippt-save-button" data-url="https://kippt.com/karrisaarinen/" data-title="Karri Saarinen on Kippt" data-source="example.com">Save to Kippt</a>
    
    <script>(function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="http://addons.kippt.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","kippt-wjs"));</script>
    

    Linkedin

    <script src="//platform.linkedin.com/in.js" type="text/javascript">
     lang: en_US
    </script>
    <script type="IN/Share" data-counter="right"></script>
    

    原文 Social sharing buttons
    翻译 SegmentFault

  • 相关阅读:
    js获取服务器值以及服务器获取客户端值
    兼容IE Firefox的table自动换行
    sql行转列,列转行
    JS 压缩解压工具
    ASP.NET组织结构图的画法——数据来源读取数据库
    ANGULAR7的应用和跨域问题解决
    Ajax的使用之ScriptManager
    【.NET序列化和反序列化】基本篇
    Web Service的安全访问【SoapHeader身份认证】
    【C#3.0本质论 第一章】C#和.NET Framework概览
  • 原文地址:https://www.cnblogs.com/10manongit/p/12683655.html
Copyright © 2020-2023  润新知