Hi
We’ve had an issue using the iframe based integration of the twitter follow button and having callbacks working. When the iframe option is used, the callbacks specified doesn’t seem to work. Here’s a simple example that shows this - http://jsfiddle.net/imranbohoran/k7BZ8/8/
We’ve tried the anchor based approach and with that the callbacks seem to be working ok - http://jsfiddle.net/imranbohoran/kDqB8/19/
Can some one confirm if the callbacks don’t work/not supported with the iframe option?
Cheers – Imran
Sorry, callbacks are not supported in the IFRAME implementation.
Thanks for your response. Do you think it’d be useful having a note in the documentation in the IFRAME integration section about this (possibly for others who might have the same question)?
Thank you for the question this has been bothering me for some time.
If you use the iframe implementation but change the href from /share to /intent/tweet, the twitter button renders as the iframe but then you can use twttr.events.bind(‘tweet’, function(event) { //Do Something! }); to bind events as per the intents approach documented: https://dev.twitter.com/docs/intents#tweet-intent
twttr.events.bind(‘tweet’, function(event) { //Do Something! });
If you pass additional param to src, you will be able to listen for events. But i think it’s more like a hack
#_=1384154225969 - is a valid timestamp
#_=1384154225969
Can you post the event this calls back to? is it similar to this?
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="//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")); window.twttr.ready(function (twttr) { twttr.events.bind('tweet', function (event) { console.log('tweet'); }); });
window.twttr.ready(function (twttr) {
twttr.events.bind('tweet', function (event) { console.log('tweet'); });
});