Scripts — Javascript Browser & OS Detection

Browser Detector Scripts — Javascript

Your Computer Box

We've been asked how to implement the "Your Computer Information" box on this page, so we put it in a script.

Download: 'Your Computer' Box Script
Current Version: 1.3.4
File Last Modified: February 16, 2014. 18:02:39 pm

This script is a simplified version of the one to your left, for easy use.

PHP Language Detection

NEW! - PHP system language detection script. Check it out if that's something you need for your site.

These are our basic Javascript browser detection scripts. The main javascript browser detection script has been tested on every browser we have been able to get a hold of, from Opera 4-7, Mozilla 0.9-1.7, Firebird 0.6/0.7, Firefox 0.8-9, Netscape 3-4, 6.2, 7.x, to IE 4.x-6.x, as well as on the new Safari/konqueror code based Mac browsers. They are being used in one form or another on our most of our sites. The main detection script has recently undergone a complete revision, and should do a much better job for you now.

Your Computer

Operating System:

Windows
NT (version unknown)

Current Browser / UA:

User Agent: Applewebkit 537.36
Layout Engine: Webkit
Engine Version: 537.36

HTML Support

HTML 5 Basic: Good
HTML 5 Forms: Good
XHTML: No

JavaScript

PHP Browser Detection

Run Time: 0.00005698 Seconds

All scripts have been thoroughly tested, although of course no script is ever perfect, so they will be modified as time goes by. There is a 'last modified by' date scripted in next to each download so you can see if it has changed from the version you have. Please post any bugs or detection failure issues in our web programming forum, and we'll get it fixed.

The main javascript browser detection script also includes basic OS detection, that can be made more complex if required, but we have found little reason to do that so far with javascript based solutions. We prefer to use mostly PHP server side browser detection, since that does not depend on the browser having javascript enabled.

The browser detection box to your left uses our main PHP browser detector script, which is much more powerful than the javascript version.


NEW!!! Netscape/Firefox/Gecko version detection

We finally got around to to updating fully the main Javascript browser detection script. Now it id's most gecko based browsers, Firefox, Phoenix, Mozilla, Firebird, and also Konqueror and Safari, including their version numbers and rv numbers, if applicable. You can check it out by clicking on this Javascript Browser Test link.

As of version 4.2.0 the Mozilla version number is much more powerful, using regular expressions to extract the full rv and version numbers, for example rv: 1.8a2, Firefox 0.8.0+ will be correctly id'ed. All basic comparisons still use the 'nu', which is drawn from the 3 digit rv version, so you can compare versions, like:
if (moz && nu > 1.3) use some custom code. This seems to be working quite well.


Please Link to our Site

It would really help us out, and help other people find this information, if you could add a link to our site in exchange for these scripts. Thanks.

<a href = "http://techpatterns.com/downloads/javascript_browser_detection.php"> Javascript Browser Detection</a>

The Most Important Thing to Remember

If your page functioning depends on a browser supporting a Javascript/Ecmascript method, then test for the method first, not the browser, that is by far the safest way to do this. Then you can apply specific little fixes for one browser or another after that main test is carried out. Do not do general testing, for example:
if ( document.getElementById( ) ){statements....}
use the actual javacript method you need in your function, for example:
if (document.body.clientHeight && document.body.clientWidth){statements...}
(In this case, Netscape 6.0 would pass test one, but would fail test 2.)

top

Full Featured Javascript Browser Detection Script

Download: Main Javascript Browser Detection Script
Current Version: 4.2.4
File Last Modified: June 29, 2007. 14:54:33 pm

All you need to do to use this script is paste it into either your linked javascript library file that is called in the head tag, or paste the code into your head tag, using the <script>put code here</script> method.

This text file includes directions, along with a sample use of the script. We also have a very complex array based version, but it needs work, so that will come at a later time. Of course, you really should rely on method and object based testing, since there are too many browsers to support using this kind of technique.

The main advantage of this script is that it will not be fooled by Opera or Safari, even though Safari has the word 'Gecko' in its user agent string, and Opera can identify itself in several different ways, since the first thing tested for is Opera, the second, Safari, and if it's either of these, the test stops executing.

This code is more or less what we use for all our websites, in one form or another. The script will detect MSIE, Opera, Konqueror, Safari, and most of the Gecko browsers, including version and rv numbers when applicable.

top

Simple Javascript Browser Detection Script

Download: Basic Javascript Browser Detection Script
Current Version: 2.0.2
File Last Modified: June 29, 2007. 14:54:34 pm

This is the simple, bare bones script, for basic things like detecting Netscape 4. You can paste that into either your linked javascript library file that is called in the head tag, or paste the code into your head tag, using the <script>put code here</script> method.

Manual Downloads

If for some reason the above download links didn't work, you can download these here:


Site Information

W3C Validation:

XHTML CSS

Site hosted by:

pair
networks

Site Features

Utilities

Javascript Browser Test

Download Notes

Generic programs like MS Notepad will not open these downloaded text files correctly.

Please use your text editor (for example, our personal favorite, EditPlus, or HTML-Kit, BB edit, etc. to open them.

If you just want to take a look at them in your browser, go to the bottom of the page and click the Manual Download links.