我使用的是劇本我found here動態生成短鏈接,我的資料Tweet按鈕,它工作得很好,但我不能似乎做的唯一的事情就是創建一個鏈接打開無論是新標籤還是最好是一個彈出窗口。Bitly API - JavaScript函數打開新窗口
我已經試過了腳本的window.location的部分的一些變化,但到目前爲止我沒有運氣。如果有人能夠直接指出我的話,我會非常感激。
這是我使用的腳本...
<script>
var TweetThisLink = {
shorten: function(e) {
// this stops the click, which will later be handled in the response method
e.preventDefault();
// find the link starting at the second 'http://'
var url = this.href.substr(this.href.indexOf('http:', 5));
BitlyClient.shorten(url, 'TweetThisLink.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', TweetThisLink.shorten);
</script>
提前:)
嗨大衛,非常感謝您的回答,但不幸的是它並不適合我。請原諒我,因爲我的JS技能是微不足道的,但在縮短函數的地方,你會建議我放置window.open?並在響應中的win.location同樣呢?然後,我仍然使用jquery綁定來加入縮短的鏈接? – robolist