getURL: length, same window
So, linking to a url outside of the swf. Wanted to open the url in the same browser window each time. You’d think that getURL(myURL, “myWindow”) would always open the same window. But, it’s inconsistent. So, you can call JavaScript to force the same window to open - but, the character length of the url has to be a lot shorter for the JavaScript call to work. Anyway, this was a pain, hopefully this will save someone a few hours of mind-numbingly-boring testing.
public function load(url_ : String) : Void {
//this doesn't work if over a certain length
if (url_.length< =165){
//957 works for MIE7 and FireFox - this works for MIE 6.029... (really long version #)
//if (url_.length<=957){
var urlToCall : String;
urlToCall="javascript:var popWin; if (!popWin || popWin.closed) {popWin = window.open('"+url_+"','popWinName')} else {popWin.focus(); popWin.location.replace('"+url_+"');}; void(0);";
getURL (urlToCall);
}else{
//call doesn't happen if over 2041
if (url_.length>2041){
url_=url_.slice(0,2041);
}
getURL(url_, “myWindow”);
}
}
Tested on FireFox 2.004. MIE 7 and MIE 6.029 - WinXP. Swf published for Player 7 using MTASC 1.12. Swf embedded using swfObject.
Obviously this not really Flash’s fault but some combination of Flash, JavaScript, and the browser. Browsers suck.
Comments
Leave a Reply