Custom design for Twitter button with events

I’ve got a custom tweet button:

<a href=";text=myText;size=l&amp;count=none" target="_blank">
        <img src="/assets/twitter-logo.jpg">

Now I want to achieve some result after the tweet has been published. To do so, I’ve looked at the Twitter Events API:

<script type="text/javascript" src=""></script>
<script type="text/javascript">'tweet', function (event) {
        alert("Tweet Successful");

However, this API only works on non-custom buttons (twitter-share-button class).

Anyone has managed to create a custom button which listens to events?

You can have a custom link and still have the web intents!

The key is, instead of your link pointing to “” it should point to “

like this:

<a href="">Tweet</a>

This way you can use the web intents like you were trying:'tweet', function (event) {
  // Do something there

Check this jsFiddle

I got some one with a share action

<a href="" class="twitter-share-button" data-via="pincheregio" data-size="large" data-count="none">Tweet</a>

    !function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);;js.src=p+'://';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>

      twttr.ready(function (twttr) {'tweet', function (event) {


DO NOT WASTE your time with “tweet” event. Unlike other social networks, twitter will fire this even regardless was the tweet successfully completed or user just closed the window. So instead use code bellow:

jQuery('#twitter').off('click').on('click', function() {
  var field_list = {
    url: '',
    text: 'Some random text',
    hashtags: 'myhashtag,anothertag',
  }''+jQuery.param(field_list), '_blank', 'width=550,height=420').focus();

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .
Read More:   gapless looping audio html5

Similar Posts