2012-06-11 36 views
15

我想知道是否有一種方法爲Facebook,Twitter和Google +1創建「分享」按鈕,而不使用任何Javascript必須在任何時候插入代碼中。僅使用HTML(無Javascript)的Facebook,Twitter和Google +1按鈕

例如,您可以使用下面描述的方法動態創建這些按鈕;但他們都最終動態加載Javascript和建立在幕後自己的代碼:

回答

24

以下鏈接將註冊相應的喜歡,推文和+ 1s:

這些鏈接將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> 

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

請問Facebook網址採取任何更多的PARAMS?或者它只是'你'? – henrywright

+0

@henrywright看來Facebook現在更喜歡不同的語法;答案中的URL有效,但這裏有更多關於如何使用共享對話框的信息:https://developers.facebook.com/docs/sharing/reference/share-dialog#redirect關於遺留網址的選項,看到這篇文章:http://ar.zu.my/how-to-really-customize-the-deprecated-facebook-sharer-dot-php/ –

+0

感謝您的跟進。我會看看鏈接... – henrywright

6

谷歌加在上面的例子中不能正常工作。

我用這個谷歌加。

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

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> 

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

來源:

2

這是提供您正在尋找的答案,而無需使用任何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> 
相關問題