【问题标题】:Facebook, Twitter, and Google +1 buttons using only HTML (No Javascript)仅使用 HTML(无 Javascript)的 Facebook、Twitter 和 Google +1 按钮
【发布时间】:2012-06-14 20:56:04
【问题描述】:

我想知道是否有一种方法可以只使用 HTML 为 Facebook、Twitter 和 Google +1 创建“分享”按钮,而无需在任何时候将任何 Javascript 插入代码中。

例如,您可以使用下面描述的方法来动态创建这些按钮;然而,他们最终都动态加载 Javascript 并在幕后创建自己的代码:

【问题讨论】:

    标签: html facebook url twitter google-plus-one


    【解决方案1】:

    这是一篇非常有用的文章,它在不使用任何 PHP 的情况下提供了您正在寻找的答案 - http://www.hanselman.com/blog/AddSocialSharingLinksToYourBlogWithoutWidgetJavaScript.aspx

    推特

    <a href="https://twitter.com/intent/tweet?url=YOURURLHERE&text=YOURPOSTTITLEHERE&via=YOURTWITTERNAMEHERE">Twitter</a>
    

    脸书

    <a href="https://facebook.com/sharer.php?u=YOURURLHERE">Facebook</a>
    

    GOOGLE+

    <a href="https://plus.google.com/share?url=YOURURLHERE">Google+</a>
    

    【讨论】:

      【解决方案2】:

      google plus 在上述示例中不起作用。

      我将这个用于 google plus。

      <div id="custom-google-button">
        <a href="https://plus.google.com/share?&hl=en&url=YOUR_URL_to_share" target="_blank">google+</a>
      </div>
      

      在 Wordpress 中:

      <a href="https://plus.google.com/share?hl=en&url=<?php if(is_home()){echo home_url();}else{the_permalink();} ?>" target="_blank" title="Plus one this page on Google">google+</a>
      

      领英:

      <div id="custom-linkedin-button">
        <a href="http://www.linkedin.com/shareArticle?mini=true&url=YOUR_URL_to_share" target="_blank">Linkedin</a>
      </div>
      

      在 Wordpress 中:

      <a href="http://www.linkedin.com/shareArticle?mini=true&url=<?php if(is_home()){echo home_url();}else{the_permalink();} ?>" target="_blank">Linkedin</a> 
      

      来源:

      【讨论】:

        【解决方案3】:

        以下链接将记录相应的点赞、推文和 +1:

        这些链接适用于 Wordpress:

        脸书

        <a href="http://www.facebook.com/sharer.php?u=<?php if(is_home()){echo home_url();}else{the_permalink();} ?>" target="_blank" title="Share this page on Facebook">Like</a>
        

        推特

        <a href="http://twitter.com/share?url=<?php if(is_home()){echo home_url();}else{the_permalink();} ?>&text=<?php the_title(); ?>" target="_blank" title="Tweet this page on Twitter">Tweet</a>
        

        谷歌+1

        <a href="https://plusone.google.com/_/+1/confirm?hl=en&url=<?php if(is_home()){echo home_url();}else{the_permalink();} ?>" target="_blank" title="Plus one this page on Google">+1</a>
        

        【讨论】:

        • Facebook url 是否需要更多参数?还是只是u
        • @henrywright 似乎 Facebook 现在更喜欢不同的语法;答案中的 URL 有效,但这里有更多关于如何使用共享对话框执行此操作的信息:developers.facebook.com/docs/sharing/reference/… 关于旧 URL 的选项,请参阅这篇文章:ar.zu.my/…
        猜你喜欢
        • 2013-12-10
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-10-25
        • 2011-06-13
        • 2012-02-26
        • 2011-11-25
        • 1970-01-01
        相关资源
        最近更新 更多