Drew Bartlett
Drew Bartlett

Reputation: 1901

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

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

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?

Upvotes: 0

Views: 2257

Answers (1)

abraham
abraham

Reputation: 47893

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.

Upvotes: 7

Related Questions