Tuesday, October 16, 2012

Tweet button for your web site

Hi, I was looking for a service url for tweeting from a web site with a web url as a link to your web site. Finally found it. Here it is.
<script >
function tweet(text, url){
     var windowWidth=750;
     var windowHeight=500;
     var centerWidth = (window.screen.width - windowWidth) / 2;
     var centerHeight = (window.screen.height - windowHeight) / 2;

     var sharing_url=encodeURIComponent(url);
        var tweetWindow = window.open('http://twitter.com/share?url='+sharing_url+'&text='+text,'tweet_share','resizable=0,width=' + windowWidth + 
     ',height=' + windowHeight + 
        ',left=' + centerWidth + 
        ',top=' + centerHeight);
        tweetWindow.focus();
        return false;

   
}
</script>

Further I have experiences in tweeting a working url (with a public domain name) inside the tweet text. Twitter nicely identifies it as a link. Thanks.

No comments:

Post a Comment