开发者

How to disable the screen name when loading twitter follow button asynchronously

开发者 https://www.devze.com 2023-03-15 04:14 出处:网络
<script type=\"text/javascript\"> (functio开发者_高级运维n(){ var twitterWidgets = document.createElement(\'script\');
<script type="text/javascript">
  (functio开发者_高级运维n(){
    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>

When this loads, i need it to just show just the follow button, not the name of who you're following. When using the iframe you can add a query argument for show_screen_name.

I tried doing this:

twitterWidgets.show_screen_name = false;

but it didn't work. Any ideas?


You can do it with data-show-screen-name="false" like this:

<a href="http://twitter.com/twitterapi" class="twitter-follow-button" data-show-screen-name="false">Follow @twitterapi</a>

Twitter has a special note with this option:

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消