Answers

Jun 14, 2007 - 05:36 AM
* @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;
};

Jun 14, 2007 - 02:42 PM
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
So your best bet to identify individual browsers nowadays is to use userAgent and which euzuro has given you the answer to your question.
You can use the navigator object to determine other things as well like version (use indexOf) and os. A sample function can be found here http://www.quirksmode.org/js/detect.html

Jun 16, 2007 - 02:45 AM
Two versions simple and full featured
http://techpatterns.com/downloads/jav...

Sep 27, 2007 - 01:08 AM
http://www.mistered.us/tips/javascrip...

Oct 12, 2007 - 02:59 AM
navigator.appName

Oct 18, 2007 - 03:15 AM
Add New Comment