<script type="text/javascript">
(function(){
var twitterWidgets = document.createElement('script');
twitterWidgets.type = 'text/javascript';
twitterWidgets.async = true;
twitterWidgets.src = 'http://platform.twitter.com/widgets.js';
document.getElementsByTagName('head')[0].appendChild(twitterWidgets);
})();
</script>
加载时,我需要它只显示关注按钮,而不是您关注的人的姓名。使用 iframe 时,您可以为 show_screen_name 添加查询参数。
我尝试这样做:
twitterWidgets.show_screen_name = false;
但是没有成功。有什么想法吗?
最佳答案
您可以使用 data-show-screen-name="false"
来完成此操作,如下所示:
<a href="http://twitter.com/twitterapi" class="twitter-follow-button" data-show-screen-name="false">Follow @twitterapi</a>
Twitter 对这个选项有一个特别说明:
Note that if you decide to set the show_screen_name parameter to false, you’ll still have to display “manually” which @username the Follow button is interacting with. In other words, it has to be very clear who the user is going to follow by clicking your Follow Button.
关于javascript - 如何在异步加载 Twitter 关注按钮时禁用屏幕名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6457504/