[英]Creating a Twitter Follow List Item in Javascript
Trying to get a list item(li) working so when clicked it opens the Twitter Follow dialogue box. 尝试使列表项(li)运行正常,因此在单击该列表项时会打开“ Twitter关注”对话框。 I have tweaked the code slightly to try and get it working with a link within a list item but doesn't seem to be working correctly. 我对代码进行了一些微调,以尝试使其与列表项中的链接一起使用,但似乎无法正常工作。
Can anyone spot the error? 谁能发现错误?
<li class="main_news">
<a href="https://twitter.com/amazon">
<script>
! function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0],
p = /^http:/.test(d.location) ? 'http' : 'https';
if (!d.getElementById(id)) {
js = d.createElement(s);
js.id = id;
js.src = p + '://platform.twitter.com/widgets.js';
fjs.parentNode.insertBefore(js, fjs);
}
}(document, 'script', 'twitter-wjs');
</script>
</li>
The code is taken from https://about.twitter.com/resources/buttons#follow 该代码来自https://about.twitter.com/resources/buttons#follow
Custom styled anchor that still opens the "official" Twitter popup. 自定义样式的锚点仍会打开“官方” Twitter弹出窗口。
Based on https://geekgoddess.com/use-custom-graphic-for-twitter-follow-button/ 基于https://geekgoddess.com/use-custom-graphic-for-twitter-follow-button/
<li class="main_news">
<a href="https://twitter.com/intent/follow?screen_name=amazon">Follow @amazon</a>
</li>
<script src="https://platform.twitter.com/widgets.js"></script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.