Getting the Name of the Browser
-
I ran the following JavaScript code: alert( "browers is " + navigator.appName ); The browser I was using is Chrome. I expected to get the string Google Chrome but instead I got: Am I missing something? I am thinking that my security software is changing the name of the string to protect my system and/or my privacy. Is that right? Thanks, Bob
-
I ran the following JavaScript code: alert( "browers is " + navigator.appName ); The browser I was using is Chrome. I expected to get the string Google Chrome but instead I got: Am I missing something? I am thinking that my security software is changing the name of the string to protect my system and/or my privacy. Is that right? Thanks, Bob
It doesn't look like that property has much value Navigator appName Property[^] If you want to know the browser you'll probably need to interrogate the user agent How to Use JavaScript to Detect Browser | Learning jQuery[^] These days doing things depending on the browser is frowned upon, instead you should interrogate the browser to see if it supports the feature you want to use.
-
I ran the following JavaScript code: alert( "browers is " + navigator.appName ); The browser I was using is Chrome. I expected to get the string Google Chrome but instead I got: Am I missing something? I am thinking that my security software is changing the name of the string to protect my system and/or my privacy. Is that right? Thanks, Bob
NavigatorID.appName - Web APIs | MDN[^]:
This feature has been removed from the Web standards. Though some browsers may still support it, it is in the process of being dropped. Avoid using it and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time. ... Do not rely on this property to return the correct browser name. In most browsers (like Firefox, Chrome, Safari, Opera and Internet Explorer) the returned string is "Netscape".
You should generally avoid browser detection, and use feature detection instead: Browser Detection (and What to Do Instead)[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
It doesn't look like that property has much value Navigator appName Property[^] If you want to know the browser you'll probably need to interrogate the user agent How to Use JavaScript to Detect Browser | Learning jQuery[^] These days doing things depending on the browser is frowned upon, instead you should interrogate the browser to see if it supports the feature you want to use.
It is true that you should check to see if a browswer supports the feature you wish to use. As for the fact that the alert returns Nestscape goes back to the history of Javascript. Here is a quick Google research post (hope you can see why it returns Netscape' 'JavaScript, not to be confused with Java, was created in 10 days in May 1995 by Brendan Eich, then working at Netscape and now of Mozilla. JavaScript was not always known as JavaScript: the original name was Mocha, a name chosen by Marc Andreessen, founder of Netscape.Jun 27, 2012'