Thursday, December 22, 2011

Twitter call back function


<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" charset="utf-8">
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"));
 twttr.ready(function (twttr) {
 twttr.events.bind('tweet', function (event) {
alert('testing');
    });
 });
var myurl = "http://www.google.com";
var mytext = "Text";
var url = "https://twitter.com/intent/tweet" + 
 "?url=" + encodeURIComponent(myurl) + 
 "&text=" + encodeURIComponent(mytext);
 document.getElementById("shareLink").href = url; 
 </script>
</head>
<body>
<a id="shareLink" href="https://twitter.com/intent/tweet">Tweet</a>
</body>
</html>
OUTPUT:










Click here for twitter callback test