mattlundstrom
6/15/2012 - 7:04 PM

Flash get browser name

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);
		}