Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

FAQ Topic - How do I detect Opera/Netscape/IE? (2009-06-24)

0 views
Skip to first unread message

FAQ server

unread,
Jun 23, 2009, 7:00:02 PM6/23/09
to
-----------------------------------------------------------------------
FAQ Topic - How do I detect Opera/Netscape/IE?
-----------------------------------------------------------------------

The ` navigator ` object contains strings which
specify the browser and version; however, this is in general not
very genuine. Mozilla (and therefore Netscape 6+) allows this to
be freely set, and Opera and IE allow it to be modified. There
are also at least 25 other javascript capable browsers with
their own strings here.

Generally though, you don't need to identify which browser is
being used. There are alternative techniques, but which one you
choose depends on why you want to redirect browsers. If it's to
offer different CSS stylesheets, then

http://w3development.de/css/hide_css_from_browsers/

shows many techniques. For Scripting, _object_ detection
is a better method to use.

http://www.quirksmode.org/js/support.html

It is also known as feature detection.

Object/feature detection means checking that the object you wish
to use is supported by the browser before using it. This means
that you don't need to know what browsers support what methods,
and your code will automatically be usable on any browser that
can execute it.

if (document.getElementById &&
document.getElementById('el') &&
document.getElementById('el').style ) {
// We know that this browser supports getElementById and has
// a style object, so we can set a style property.
document.getElementById('el').style.color = "red";
}

Browser bugs can often be detected and overcome in similar ways.

http://developer.mozilla.org/en/docs/Using_Web_Standards_in_your_Web_Pages:Developing_Cross_Browser/Cross_Platform_Pages

http://www.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


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.

0 new messages