/**
* @returns A string which specifies which is the current
* browser in which we are running.
*
* Currently-supported browser detection and codes:
* * 'opera' -- Opera
* * 'msie' -- Internet Explorer
* * 'safari' -- Safari
* * 'firefox' -- FireFox
* * 'mozilla' -- Mozilla
*
* If we are unable to property identify the browser, we
* return an empty string.
*
* @type String
*/
OpenLayers.Util.getBrowserName = function() {
var browserName = "";
var ua = navigator.userAgent.toLowerCase();
if ( ua.indexOf( "opera" ) != -1 ) {
browserName = "opera";
} else if ( ua.indexOf( "msie" ) != -1 ) {
browserName = "msie";
} else if ( ua.indexOf( "safari" ) != -1 ) {
browserName = "safari";
} else if ( ua.indexOf( "mozilla" ) != -1 ) {
if ( ua.indexOf( "firefox" ) != -1 ) {
browserName = "firefox";
} else {
browserName = "mozilla";
}
}
return browserName;
};
nidhi
Date:: Jun 14, 2007
Time:: 17:42
For info only, this is old skool, useful really only if you wanted to check for IE
Before it was possible to use appName, but both Mozilla and Safari both return Netscape which is why you cant really use it now.
the navigator object is a throwback from Netscape Navigator days I believe hence the use of that keyword.
simple test I used. This is for information only, it is not something you should be using. As I said before, only handy if you want to check for MSIE only.
Yo
No comments:
Post a Comment