Jump to content

Why Netscape when I am using Chrome?


YigalB

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/256344-why-netscape-when-i-am-using-chrome/
Share on other sites

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.

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.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.