Last active
August 29, 2015 14:05
-
-
Save kfitfk/914f5e61afb307da3c9f to your computer and use it in GitHub Desktop.
Open Browser Window in ActionScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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