1

在我网站的某个页面上,用户有一个项目列表,如下所示:

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

有没有一个插件可以做到这一点?

4

1 回答 1

3

不需要第三方插件。使用Twitter 插件

<!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>
于 2012-08-10T08:41:41.480 回答