YigalB Posted February 3, 2012 Share Posted February 3, 2012 Running this JS code: <script type="text/javascript" language="javascript"> document.write("Using: " + navigator.appName + "</p>"); document.write("Version: " + navigator.appVersion + "</p>"); The result was: Using: Netscape Version: 5.0 (X11; Linux i686) AppleWebKit/535.2 (KHTML, like Gecko) Ubuntu/11.10 Chromium/15.0.874.106 Chrome/15.0.874.106 Safari/535.2 Why did I get Netscape when I am actually using Chrom? And the version response includes Apple? Quote Link to comment Share on other sites More sharing options...
Adam Posted February 3, 2012 Share Posted February 3, 2012 Chrome uses NSPR and Apple WebKit, amongst a lot of other open source libraries. I can't remember why the appName property still says Netscape, but just use navigator.userAgent. Like appVersion though, the user agent will contain Apple and various other brands you probably wouldn't expect, but it's just down to the libraries used internally. Quote Link to comment Share on other sites More sharing options...
kicken Posted February 4, 2012 Share Posted February 4, 2012 Things like this is why it is a poor idea to try and determine which browser a person is using. It's far better to try and determine if the features you want are implemented and ignore which browser it is. For example if you want to use WebSockets if available, you'd do something like: if (typeof WebSocket !== 'undefined'){ //websockets are available. } rather than try and determine if the browser is chrome or whatever other ones support it now. As support grows in other browsers, your code will just start working with no need for you to do anything. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.