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

3

15

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.

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:

Chrisoula answered 11/6, 2012 at 23:38 Comment(0)
C
24

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

These links will work for Wordpress:

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

<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>
Chrisoula answered 11/6, 2012 at 23:38 Comment(2)
Does the Facebook url take any more params? Or is it just u?Brackely
@Brackely It seems Facebook now prefers a different syntax; the URL in the answer strill works, but here is more information on how to do this using the share dialog: developers.facebook.com/docs/sharing/reference/… Regarding options for the legacy URL, see this post: ar.zu.my/…Chrisoula
D
6

google plus not working in the above example.

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

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

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

Dillard answered 24/9, 2012 at 8:48 Comment(0)
P
2

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

TWITTER

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

FACEBOOK

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

GOOGLE+

<a href="https://plus.google.com/share?url=YOURURLHERE">Google+</a>
Proximo answered 25/4, 2014 at 14:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.