简体   繁体   English

在Javascript中创建Twitter关注列表项

[英]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.

相关问题 确认列表项,然后单击href - Confirmation on list item click then follow href JavaScript - 仅当用户实际关注时才触发 Twitter 意图“关注”回调 - JavaScript - Trigger Twitter intent "follow" callback only if user actually follows 让推特机器人在新的关注动作 javascript 时检索用户名 - Have twitter bot retrieve username upon new follow action javascript 如何从javascript / jquery中的Twitter Follow按钮获取锚文本? - How to get anchor text from twitter follow button in javascript / jquery? 如何使用JavaScript获取在Twitter上关注的人数? - How to get the number of people you follow on twitter using JavaScript? 是否有类似于关注事件的 Twitter 取消关注 JavaScript 事件或使其发生的方法? - Is there a Twitter unfollow JavaScript event similiar to the follow event or a way to make it happen? 我可以通过外部JavaScript文件创建Twitter“关注按钮”吗? - Can I make a Twitter Follow Button from an external JavaScript file? 创建列表项 Sharepoint REST API Javascript 返回错误 500 - Creating List Item Sharepoint REST API Javascript returns Error 500 声明元素列表遵循JavaScript诺言规则 - Asserting list of elements follow a rule with JavaScript promises “像Twitter一样”关注按钮 - “Twitter like” follow button
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM