From: FAQ server on
-----------------------------------------------------------------------
FAQ Topic - How do I detect Opera/Safari/IE?
-----------------------------------------------------------------------

The short answer: _Don't do that_.

The ` navigator ` host object contains properties which
may identify the browser and version. These properties are historically
inaccurate. Some browsers allow the user to set ` navigator.userAgent ` to any value. For
example, Firefox, (type ` about:config ` and search ` useragent `
or Safari, ` Develop > User Agent > Other... `, IE, via Registry.

Other browsers, such as Opera, provide a list of user agents
for the user to select from. There are also at least 25 other
javascript capable browsers, with multiple versions, each
with their own string.

Browser detection is unreliable, at best. It usually causes
forward-compatibility and maintenance problems. It is unrelated to the
problem or incompatiblity it is trying to solve and obscures the
problems it is used for, where it is used.

Object detection is checking that the object in question exists.

http://dev.opera.com/articles/view/using-capability-detection/

goes one step further to actually test the object,
method, or property, to see if behaves in the desired manner.

Feature Test Example:

/**
* Returns the element/object the user targeted.
* If neither DOM nor IE event model is supported, returns undefined.
* @throws TypeError if the event is not an object.
*/
function getEventTarget(e) {
e = e || window.event;
// First check for the existence of standard "target" property.
return e.target || e.srcElement;
}

http://jibbering.com/faq/faq_notes/not_browser_detect.html

http://dev.opera.com/articles/view/using-capability-detection/

http://developer.apple.com/internet/webcontent/objectdetection.html

http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.43


The complete comp.lang.javascript FAQ is at
http://jibbering.com/faq/

--

The sendings of these daily posts are proficiently hosted
by http://www.pair.com.