将click()事件附加到Twitter关注按钮? [英] Attach a click() event to the twitter follow button?

查看:104
本文介绍了将click()事件附加到Twitter关注按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户点击关注按钮时,我想在页面上添加提醒消息。
我怎么能实现这个目标?

I'd like to add a alert message on the page when a user clicks 'follow' button. how can i achieve this ?

这里是代码:

<a href="https://twitter.com/prajapat2010" class="twitter-follow-button"
data-show-count="false" data-dnt="true">Follow @prajapat2010</a>
<script>
    ! function (d, s, id) {
        var js, fjs = d.getElementsByTagName(s)[0];
        if (!d.getElementById(id)) {
            js = d.createElement(s);
            js.id = id;
            js.src = "//platform.twitter.com/widgets.js";
            fjs.parentNode.insertBefore(js, fjs);
        }
    }(document, "script", "twitter-wjs");
</script>


推荐答案

您可以使用Twitter事件回调来实现此目的。

You can use Twitter event callback to achieve this.

//Here is you normal twitter button code

//My custom function
function mycustom() {
  alert('this is a test')
}

//Bind the custom function with twitter event
twttr.ready(function (twttr) {
  twttr.events.bind('click', mycustom);
});

有关更多活动,请阅读官方文档: https://dev.twitter.com/docs/intents/events

For more events, read the official doc: https://dev.twitter.com/docs/intents/events

这篇关于将click()事件附加到Twitter关注按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆