2012-08-10 66 views
1

在我的網站的某一頁,用戶擁有的項目的列表,像這樣:顯示多個Twitter分享按鈕?

<div id="item1">.....</div> 
<div id="item2">.....</div> 
<div id="item3">.....</div> 

每這些div都有自己的網站上的某個特殊的聯繫,如:

example.com/items/1 
example.com/items/2 
example.com/items/3 

我想在每個單獨的div中顯示一個twitter共享按鈕,單擊它時會讓用戶將該特定項目的url發送到他們的twitter。

有沒有這樣做的插件?

回答

3

不需要第三方插件。去與Twitter plugin

<!DOCTYPE html> 
<html lang="de"> 
    <head> 

     <!-- meta --> 
     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
     <meta name="robots" content="noindex, nofollow"> 

     <title>Twitter Share Buttons</title> 

    </head> 
    <body> 
     <div id="item1"><a href="https://twitter.com/share" class="twitter-share-button" data-url="http://example.com/items/1" data-text="Text to share 1">Tweet</a></div> 
     <div id="item2"><a href="https://twitter.com/share" class="twitter-share-button" data-url="http://example.com/items/2" data-text="Text to share 2">Tweet</a></div> 
     <div id="item3"><a href="https://twitter.com/share" class="twitter-share-button" data-url="http://example.com/items/3" data-text="Text to share 3">Tweet</a></div> 
     <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script> 
    </body> 
</html> 
+0

感謝兄弟!!!!!!!! – 2012-08-10 09:30:47

+0

最後一個'