By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,481 Members | 1,713 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,481 IT Pros & Developers. It's quick & easy.

FAQ Topic - How do I detect Opera/Netscape/IE?

P: n/a
-----------------------------------------------------------------------
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://www.jibbering.com/faq/faq_not...er_detect.html

http://developer.apple.com/internet/...detection.html
===
Postings such as this are automatically sent once a day. Their
goal is to answer repeated questions, and to offer the content to
the community for continuous evaluation/improvement. The complete
comp.lang.javascript FAQ is at http://jibbering.com/faq/index.html.
The FAQ workers are a group of volunteers.

Mar 4 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
FAQ server said the following on 3/3/2007 7:00 PM:
-----------------------------------------------------------------------
FAQ Topic - How do I detect Opera/Netscape/IE?
-----------------------------------------------------------------------
How do I detect the user's browser?

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Mar 4 '07 #2

P: n/a
FAQ server wrote :
-----------------------------------------------------------------------
FAQ Topic - How do I detect Opera/Netscape/IE?
-----------------------------------------------------------------------
[snipped]
If it's to
offer different CSS stylesheets, then

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

shows many techniques.
That document is clearly outdated, almost rusted. The most recent
Mozilla-based browser listed in the Summary of possible methods table is
NS 6.2 (2001). And most methods based on lack of support (like child
selector, attribute selector) fail in MSIE7. So, that document is pretty
useless, definitely not FAQ-worthy.
IE conditional comment is not even mentioned, discussed or explained in
that document: that's a rather serious omission.

Gérard
--
Using Web Standards in your Web Pages (Updated Dec. 2006)
http://developer.mozilla.org/en/docs...your_Web_Pages
Mar 4 '07 #3

P: n/a
Randy Webb wrote:
FAQ server said the following on 3/3/2007 7:00 PM:
>-----------------------------------------------------------------------
FAQ Topic - How do I detect Opera/Netscape/IE?
-----------------------------------------------------------------------

How do I detect the user's browser?
Wouldn't the user's browser be implied and so not need detecting?
Determining the type/version of the user's browser is question being
asked.

Richard.

Mar 4 '07 #4

P: n/a
Richard Cornford said the following on 3/4/2007 6:39 AM:
Randy Webb wrote:
>FAQ server said the following on 3/3/2007 7:00 PM:
>>-----------------------------------------------------------------------
FAQ Topic - How do I detect Opera/Netscape/IE?
-----------------------------------------------------------------------

How do I detect the user's browser?

Wouldn't the user's browser be implied and so not need detecting?
Determining the type/version of the user's browser is question being asked.
My point was that limiting the question to Opera/Netscape/IE is very
outdated and wrong.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Mar 4 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.