开发者

How do i get some javascript code to run whenever twitter follow button is clicked, API

How do i get some javascript to run whenever a follow button is clicked in the twitter API? I'开发者_如何学Cm new to the twitter API, i know in Facebook its a event subscribe, so whats the equivalent?


You can use below code. You will get

FOLLOW!

alert after clicking on follow button

<html>
<a href=http://twitter.com/directdialogs class="twitter-follow-button"
data-show-count="true">Follow@directdialogs</a>
<script type="text/javascript" charset="utf-8">
  window.twttr = (function (d,s,id) {
    var t, js, fjs = d.getElementsByTagName(s)[0];
    if (d.getElementById(id)) return; js=d.createElement(s); js.id=id;
    js.src="//platform.twitter.com/widgets.js"; fjs.parentNode.insertBefore(js, fjs);
    return window.twttr || (t = { _e: [], ready: function(f){ t._e.push(f) } });
  }(document, "script", "twitter-wjs"));
</script>
<script>
twttr.ready(function (twttr) {
  twttr.events.bind('follow',   function(e) {
     alert("FOLLOW!")
  });
});
</script>
</html>
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜