meancode
12th August 09, 08:01 AM
I have a script I am using to create short URLs and send them to the status field in Twitter. Only I would like for this to happen in a new browser window, preferably sized to a specific height and width. I do not know how to do that. Can that functionality be added to the existing bit.ly script? I am sure it is more complicated than just using window.open.
I have tried a few different changes and non work. Can someone help?
<script type="text/javascript" charset="utf-8" src="http://bit.ly/javascript-api.js?version=latest&login=LOGIN&apiKey=APIKEY"></script>
<script type="text/javascript">
BitlyCB.shortenResponse = function(data) {
var s = '';
var first_result;
// Results are keyed by longUrl, so we need to grab the first one.
for (var r in data.results) {
first_result = data.results[r]; break;
}
// Now get the shortURL
shortURL = first_result["shortUrl"];
document.location = "http://www.twitter.com/home/?status=" + document.title.replace(/ /g,"+") + "+" + shortURL + "+(via+@example)";
}
</script>
<img style="cursor: pointer;" src="/images/tweet.gif" title="Tweet about <$MTEntryTitle encode_html="0">" onClick="BitlyClient.shorten(document.location, 'BitlyCB.shortenResponse');">
I have gotten somewhere. The below edit works in Firefox but not Safari:
windowOpenUrl = "http://www.twitter.com/home/?status=" + document.title.replace(/ /g,"+") + "+" + shortURL + "+(via+@example)";
window.open(windowOpenUrl, 'new_window', 'width=600,height=400');}
I have tried a few different changes and non work. Can someone help?
<script type="text/javascript" charset="utf-8" src="http://bit.ly/javascript-api.js?version=latest&login=LOGIN&apiKey=APIKEY"></script>
<script type="text/javascript">
BitlyCB.shortenResponse = function(data) {
var s = '';
var first_result;
// Results are keyed by longUrl, so we need to grab the first one.
for (var r in data.results) {
first_result = data.results[r]; break;
}
// Now get the shortURL
shortURL = first_result["shortUrl"];
document.location = "http://www.twitter.com/home/?status=" + document.title.replace(/ /g,"+") + "+" + shortURL + "+(via+@example)";
}
</script>
<img style="cursor: pointer;" src="/images/tweet.gif" title="Tweet about <$MTEntryTitle encode_html="0">" onClick="BitlyClient.shorten(document.location, 'BitlyCB.shortenResponse');">
I have gotten somewhere. The below edit works in Firefox but not Safari:
windowOpenUrl = "http://www.twitter.com/home/?status=" + document.title.replace(/ /g,"+") + "+" + shortURL + "+(via+@example)";
window.open(windowOpenUrl, 'new_window', 'width=600,height=400');}