home / experts / javascript / column6 |
|
Browser detection is not recommended because it checks what browser the user is running, not what features are supported. So if your script depends on browser detection to decide whether or not to execute a specific function or script segment, it might not work with future browers. The number of browsers and browser versions is constantly growing, and so is the number of inconsistent features. Furthermore, you must be a JavaScript hacker to know exactly what features are supported by each browser. Is As you already know, if you refer to an object (or a property, method, function, etc.) that is not supported, the browser cannot execute the script, and it displays a very annoying error message. Object detection simply checks if an object exists before you use it in the script. We used object detection in our column "Universal JavaScript Rollovers" to find out if the browser supports the
The general syntax for object detection is:
A few restrictions apply to the object in the conditional statement:
We all know that an |
Created: November 4, 1997
Revised: December 4, 1997
URL: http://www.webreference.com/js/column6/object.html