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
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.

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.