开发者

Twitter Javascript API: adding Web Intent events

I need to handle 'tweet' event. That is what I have now, but it doesn't work:

<script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
<script type="text/java开发者_开发知识库script">

function jsTweet() {

   // some other stuf here
   // ...

   var urlTW = "https://twitter.com/intent/tweet?text=Text&url=http://my_url.com";
   var winTW = window.open(urlTW,'','toolbar=0, status=0, width=650, height=360');
}

(function() {
    twttr.events.bind('tweet', function(event) {
        alert('tweet!!!!');
    });
}());
</script>

<a href="javascript:void(0)" onClick="jsTweet();">


Several things :

1/ Close your anchor tag.

2/ Your anonymous function is called only when the page is loaded. The twttr object doesn't exist at this time. So there is no binding done. Debug your function with Firebug or something, this should appear as an error.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜