Skip to content

Instantly share code, notes, and snippets.

@mattlundstrom
Created June 15, 2012 19:04
Show Gist options
  • Save mattlundstrom/2938211 to your computer and use it in GitHub Desktop.
Save mattlundstrom/2938211 to your computer and use it in GitHub Desktop.
Flash get browser name
function getBrowserName():String
{
var browser:String;
//Uses external interface to reach out to browser and grab browser useragent info.
var browserAgent:String = ExternalInterface.call("function getBrowser(){return navigator.userAgent;}");
//Determines brand of browser using a find index. If not found indexOf returns (-1).
if(browserAgent != null && browserAgent.indexOf("Firefox")>= 0) {
browser = "Firefox";
}
else if(browserAgent != null && browserAgent.indexOf("Safari")>= 0){
browser = "Safari";
}
else if(browserAgent != null && browserAgent.indexOf("MSIE")>= 0){
browser = "IE";
}
else if(browserAgent != null && browserAgent.indexOf("Opera")>= 0){
browser = "Opera";
}
else {
browser = "Undefined";
}
return (browser);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment