Created
June 15, 2012 19:04
-
-
Save mattlundstrom/2938211 to your computer and use it in GitHub Desktop.
Flash get browser name
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 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