I am doing the "share on Twitter" functionality. I have share button and when I click it will open a widget of twitter and showing me the share box. When I will press on Tweet button of widget , it will post my message on my twitter timeline.
now I want to handle a callback, when I tweet successfully, the pop up should not display and my website should redirect next page.
I refereed Is there a callback for Twitter's Tweet Button? this question but not working as per my requirements.
Twitter providing the events but it will execute on Tweet button which are embedded in our site. My tried with 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 next page after successful tweet?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…