开发者

Twitter Javascript API: adding Web Intent events

开发者 https://www.devze.com 2023-03-23 09:26 出处:网络
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>

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

精彩评论

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