2012-06-11 4 views
15

Me gustaría saber si existe un método para crear botones "compartir" para Facebook, Twitter y Google + 1 usando solo HTML, sin Javascript tener que ser insertado en el código en cualquier punto.Facebook, Twitter y Google +1 botones usando solo HTML (sin Javascript)

Por ejemplo, puede usar los métodos que se describen a continuación para crear estos botones dinámicamente; Sin embargo todos terminan de cargar el Javascript de forma dinámica y la creación de su propio código detrás de las escenas:

Respuesta

24

Los siguientes enlaces se registrarán los gustos apropiados, Tweets y + 1s:

estos enlaces funcionen para 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> 
+0

¿La url Facebook aguantar más params? ¿O es solo 'tú'? – henrywright

+0

@henrywright Parece que Facebook ahora prefiere una sintaxis diferente; la URL en la cadena de respuesta funciona, pero aquí hay más información sobre cómo hacerlo usando el diálogo Compartir: https://developers.facebook.com/docs/sharing/reference/share-dialog#redirect Acerca de las opciones para la URL heredada , mira esta publicación: http://ar.zu.my/how-to-really-customize-the-deprecated-facebook-sharer-dot-php/ –

+0

Gracias por dar seguimiento. Echaré un vistazo al enlace ... – henrywright

6

Google Plus no está trabajando en el ejemplo anterior.

Lo utilicé para 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> 

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

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

Fuentes:

2

Este es un artículo muy útil que proporciona la respuesta que busca sin utilizar ningún 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> 
Cuestiones relacionadas