Apply browser detection patch which will allow us to determine browser name

with a single line, which is useful for the places in the code where we care
about what browser we're dealing with.


git-svn-id: http://svn.openlayers.org/trunk/openlayers@3322 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
crschmidt
2007-06-12 17:42:11 +00:00
parent 6a2637eb20
commit 76f9234e3b
2 changed files with 75 additions and 1 deletions

View File

@@ -965,3 +965,41 @@ OpenLayers.Util.removeTail = function(url) {
}
return head;
};
/**
* @returns A two-character 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;
};