Skip to content

Instantly share code, notes, and snippets.

@kfitfk
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kfitfk/914f5e61afb307da3c9f to your computer and use it in GitHub Desktop.
Save kfitfk/914f5e61afb307da3c9f to your computer and use it in GitHub Desktop.
Open Browser Window in ActionScript
function openWindow($url:String, $window:String = "_blank"):void {
var req:URLRequest = new URLRequest($url);
if (!ExternalInterface.available) {
navigateToURL(req, $window);
} else {
try {
var strUserAgent:String = String(ExternalInterface.call("function() {return navigator.userAgent;}")).toLowerCase();
if (strUserAgent.indexOf("firefox") != -1 || (strUserAgent.indexOf("msie") != -1 && uint(strUserAgent.substr(strUserAgent.indexOf("msie") + 5, 3)) >= 7)) {
ExternalInterface.call("function(url, target){window.open(url, target);return;}", req.url, $window);
} else {
navigateToURL(req, $window);
}
}catch (error:Error) {
navigateToURL(req, $window);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment