仅使用 HTML(无 Javascript)的 Facebook、Twitter 和 Google +1 按钮

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10988815/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 00:57:58  来源:igfitidea点击:

Facebook, Twitter, and Google +1 buttons using only HTML (No Javascript)

htmlfacebookurltwittergoogle-plus-one

提问by Andrew Odri

I would like to know if there is a method to create "share" buttons for Facebook, Twitter and Google +1 using only HTML, without any Javascript having to be inserted into the code at any point.

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

For example, you can use the methods described below to create these buttons dynamically; however they all end up loading Javascript dynamically and creating their own code behind the scenes:

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

回答by Andrew Odri

The following links will register the appropriate Likes, Tweets and +1s:

以下链接将注册相应的赞、推文和 +1:

These links will work for Wordpress:

这些链接适用于 Wordpress:

Facebook

Facebook

<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>

Twitter

推特

<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>

Google +1

谷歌 +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>

回答by sunnyuff

google plus not working in the above example.

google plus 在上面的例子中不起作用。

I used this for 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>

In Wordpress :

在 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>

Linkedin :

链接:

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

In Wordpress :

在 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> 

Sources :

来源:

回答by Deano

This is a pretty useful article that provides the answer you are looking for without using any PHP - http://www.hanselman.com/blog/AddSocialSharingLinksToYourBlogWithoutWidgetJavaScript.aspx

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

TWITTER

推特

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

FACEBOOK

FACEBOOK

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

GOOGLE+

谷歌+

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