From DHTML to DOM Scripting
Full Text Search: The Key to Better Natural Language Queries for NoSQL in Node.js
Object Detection vs. Browser DependenceOne way to determine which browser is in use is by testing the navigator object, which reveals the name and the version of the browser in its appName and appVersion attributes. For example, the following script gets the browser name and version and writes it out to the document:
A lot of older scripts use this information to determine whether a browser is capable of supporting their functionality.
Tip Opera is by default set up to tell scripts that it is MSIE. The reason for this is that Opera Software didn't want its browser to be blocked by web sites that were developed for MSIE only. Sadly enough, a lot of devel-opment went that route and Opera Software just didn't want to lose customers or answer a lot of angry e-mails why its "bad" browser doesn't work with web site XYZ. However, it also means that Opera doesn't show up in browser statistics of web sites and remains unimportant for those who just see the visitor numbers and what browser they use (a lot of statistics software uses the navigator object). If you are an Opera user and you want to turn off this preset, press F12 and choose "Identify as Opera" instead of "Identify as Internet Explorer."
Reading out the browser name and version--commonly known as browser sniffing--is not advisable, not only because of the inconsistencies we just encountered, but also because it makes your script dependent on a certain browser rather than supporting any user agent that is actually capable of supporting the script.
The solution to this problem is called object detection, and it basically means that we determine whether a user agent supports a certain object and make this our key differentiator. In really old scripts, like the first image rollovers, you might have seen something like this: