Scripts — Javascript Browser & OS Detection
Browser Detector Scripts — Javascript
Your Computer Box
Download: 'Your Computer' Box Script
Current Version: 1.3.4
File Last Modified: February 16, 2014. 18:02:39 pm
PHP Language Detection
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:
Current Browser / UA:
HTML Support
JavaScript
PHP Browser Detection
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.)
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.
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:
- Full Featured Javascript Browser detection
- Simple Javascript Browser detection
- PHP Browser detection (full featured)
- PHP Browser detection (simplified version of the above)
- PHP Browser detection (if conditional)
- 'Your Computer Information'
- PHP Language Detection