I am using the "share on Twitter" functionality. I have a sharing button, and when I click on it, it will open the twitter widget and show me the field for sharing. When I click on the “Tweet” button of the widget, it will post my message on my twitter timeline.
Now I want to handle the callback, when I twist successfully, the popup should not display, and my site should redirect the next page.
I refereed Is there a callback for the Twitter button Twitter? this question, but does not work according to my requirements.
Twitter, which provides events, but it will be executed on the Tweet button, which are built into our website. I tried the following code:
<a href="https://twitter.com/share" class="twitter-share-button" data-url="http://www.pinceladasdaweb.com.br/blog/" data-via="pinceladasdaweb" data-lang="pt" data-text="Pinceladas da Web">Tweetar</a>
Js Code:
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="https://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")); twttr.ready(function (twttr) { twttr.events.bind('tweet', function () { alert('Tweeted!'); }); });
});
Is there a way to redirect to the next page after a successful tweet?
source share