iconic_creator — 2010-09-18T14:39:05-04:00 — #1
I do not plan to do anything with this and may never use, it's just for learning purposes.
This is what I don't understand. When I open Internet Explorer, the browser name still say Mozilla.
Why is this happening. Again this is not for real world use.
document.write("Browser Name: " + navigator.appCodeName);
document.write("Browser Version: " + navigator.appVersion);
document.write("Java Enabled: " + navigator.javaEnabled());
document.write("Cookies Enabled: " + navigator.cookieEnabled);
document.write("Browser Type: " + navigator.appName);
felgall — 2010-09-25T18:22:18-04:00 — #2
paul_wilkins — 2010-09-23T09:18:21-04:00 — #3
That particular script doesn't, which is where you might want to look to extend it.
It's futile to look for browser versions though. Browsers always change, and you don't want to change your code all the time to match up with them.
felgall — 2010-09-18T17:09:28-04:00 — #4
Microsoft did that deliberately as many web pages that actually did such tests were checking if the browser was Netscape 3 and so in order to fool the code into accepting IE3 as well they set the useragent to the same value as Netscape. It is because people used those fields to identify certain browsers and reject others that all browsers used the same values for the field as other browsers that were accepted. That's why all browsers have the abiliity to fill that field with the same value as recent versions of IE and Netscape use.
Opera can change the field values automatically depending on exactly what web page is being visited and so tell pages that only work on IE that it is IE and pages that only work on Firefox that it is Firefox.
In the case of Internet Explorer, Firefox, and Safari you can set the useragent to anything you like and so when the useragent says "Eat At Joe's" it is most likely one of those three browsers.
immerse — 2010-09-18T16:22:33-04:00 — #5
Are you sure you're not mixing appName and appCodeName up?
navigator.appName should give the name of the browser, while navigator.appCodeName should give what it thinks it is (for some strange reason IE thinks it's Mozilla-compatible, hah!)
OK, I just found the page where you probably got that script from and apparently my Firefox 3.6.10 browser thinks it's Netscape 5.
alexdawson — 2010-09-23T07:00:41-04:00 — #6
Being fair though, the JScript versions do have some synthesis with their version of the browser. JScript 9 = IE9, 5.8 = IE8, 5.7 = IE7, 5.6 = IE6, 5.5 = IE5.5.
raffles — 2010-09-19T15:00:36-04:00 — #7
allanp — 2010-09-19T01:13:42-04:00 — #8
Here is a page that does the same thing, but slightly differently.
Try running it in different browsers to see the result.
Opera allows you to set the user agent to Opera, Firefox or IE.
Safari does the same, plus Safari
raffles — 2010-09-20T15:42:36-04:00 — #9
raffles — 2010-09-19T15:42:20-04:00 — #10
Yes, but that doesn't tell you the version of the browser. I know it could tell you the JScript version, but that's not the same.
felgall — 2010-09-19T15:25:43-04:00 — #11
There's an even more certain way to detect IE and that is using JScript conditional comments.
alert('This browser is running JScript and is therefore Internet Explorer');
system — 2010-09-25T11:26:09-04:00 — #12
Pfft. Browser sniffing, what is this 1997?
Browser sniffing is most always made of total /FAIL/ -- you should be detecting capabilities as needed, not the browser.
felgall — 2010-09-20T02:32:32-04:00 — #13
It would still be more efficient to wrap the code that tests for what version of IE that it is inside the jscript conditional comment so that it doesn't even try to run for other browsers which don't have an IE version number.
felgall — 2010-09-19T15:22:04-04:00 — #14
Safari also has a setting allowing you to change the useragent to anything at all.
force — 2010-09-18T14:50:19-04:00 — #15
Are you sure you're not opening Firefox? Firefox will show as "Mozilla". IE should only show as "Internet Explorer".