I have implemented a script that dynamically generates short links for my Tweet buttons. It is working perfectly fine, but I am encountering an issue with opening the link either in a new tab or a popup window.
I've tried adjusting the window.location section of the script but haven't been successful so far. Any help directing me in the right path would be greatly appreciated.
This is the script I'm currently using...
<script>
var SocialLinkGenerator = {
shorten: function(e) {
e.preventDefault();
var url = this.href.substr(this.href.indexOf('http:', 5));
BitlyClient.shorten(url, 'SocialLinkGenerator.response');
},
response: function(data) {
var bitly_link = null;
for (var r in data.results) {
bitly_link = data.results[r]['shortUrl'];
break;
}
var tweet_text = "Text for the Tweet goes here"
window.location = "http://twitter.com/home?status=" + encodeURIComponent(tweet_text + ' ' + bitly_link + " #Hashtag1 #Hashtag2");
}
}
jQuery('.tweetlink').bind('click', SocialLinkGenerator.shorten);
</script>
Thank you very much in advance :)