gpt4 book ai didi

javascript - 显示多个 Twitter 分享按钮?

转载 作者:行者123 更新时间:2023-11-30 13:16:26 26 4
gpt4 key购买 nike

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

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

有插件吗?

最佳答案

无需第三方插件。使用 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>

关于javascript - 显示多个 Twitter 分享按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11894073/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com