PDA

View Full Version : Browser Detection



Titan85
07-02-2007, 04:51 AM
Hello, I am trying to make a script that will display a popup message if the user is on IE 6. I used to know how to do this, but haven't done it in so long that I forgot. I am assuming that it should look something like this:
if (browser detection code = ie6) alert("My text");How do I go about finding what browser is being used? Thanks

codeexploiter
07-02-2007, 06:56 AM
You can use the following function which will return true if the browser is IE 6.



function isExplorer6() {
var appVer = navigator.appVersion;
appVer = appVer.split(';');
if(appVer[1] == ' MSIE 6.0') {
return true;
}
}

Twey
07-02-2007, 07:03 AM
You really shouldn't use browser detection: it's impossible to completely accurately detect the browser without knowing and testing the features of every browser that does or will exist. To detect IE, I suggest conditional comments:
<script type="text/javascript">
var ie6 = false;
</script>
<!--[if IE eq 6]>
<script type="text/javascript">
ie6 = true;
</script>
<![endif]-->... but even this should be avoided if possible.
You can use the following function which will return true if the browser is IE 6.Unless the browser is using a different UA string, such as Avant or AOL, of course. Then there's spoofing of the UA to consider, possible future modifications to the browser that might change the format of the UA string slightly...

Titan85
07-02-2007, 01:06 PM
Thanks guys, both of your information was helpful.

SayJumner
07-27-2007, 08:34 PM
I want a script that will detect what browser the surfer is using and alert them it is best viewed with browsers and versions i state. is this script the one i want? or can you help me find another better one?

Twey
07-27-2007, 09:03 PM
Please don't do that... there are few "features" of websites that irritate me more. If the site is really unusable in browsers other than the one(s) you've chosen, it's broken. A proper standards-compliant site should work with any browser -- that's the point of standards. If it's still usable but perhaps benefits from features of certain browsers, you might want to make a small note at the bottom of the page that the page has features that will only work in those browsers. There's certainly no need for anything as intrusive as an alert.

aarffy
05-01-2009, 03:42 PM
A proper standards-compliant site should work with any browser -- that's the point of standards.

Seems like a strange position to take in a thread discussing IE6. Microsoft has been cheerfully non-compliant for years.

A proper standards-compliant site can easily crash in IE6; whether it's a good idea to have one is another subject. At this writing, IE6 seems to be down to an 18% market share, thankfully.

molendijk
05-01-2009, 11:34 PM
Seems like a strange position to take in a thread discussing IE6. Microsoft has been cheerfully non-compliant for years.
So you are saying you can be non-compliant because IE is non-compliant?

A proper standards-compliant site can easily crash in IE6.
What do you want to imply by that? You mean that a non-compliant site has less chance of crashing in IE6?
===
Arie.

aarffy
04-28-2010, 06:17 PM
I'm not implying anything. A standards compliant site can easily crash in IE6. There's no point in saying that it can't.

traq
04-28-2010, 08:40 PM
...A proper standards-compliant site should work with any browser
I agree with that completely - until we start talking about IE6. Unfortunately, "should" is your operative word, and in practice it doesn't. It's a lot of extra work to make everything work correctly in older versions of IE and modern browsers.

There's certainly no need for anything as intrusive as an alert.
I agree with that too. It's easy enough to turn off stuff that doesn't work in <IE6. And if it's something important, then we can offer a notice via conditional comments.

BLiZZaRD
04-28-2010, 09:31 PM
Why code for IE6 at all? Besides being almost a decade old and 2.5 versions outdated, it has a proven steady decline in reach statistics of 0.8% per Month, and currently is only installed (not used, installed) on less than 7% of all internet connected computers.

Why the bother? I guess it's a silly as reviving a near 3 year old thread to make a current point....

djr33
04-28-2010, 11:34 PM
I agree. This discussion is too old to be useful. Due to that I'm going to close it. If someone has a good reason to re-open it, then send a private message to a mod.

traq
04-29-2010, 01:21 AM
whoops - sorry! I didn't look at the OP date

djr33
04-29-2010, 02:17 AM
Understandable, since there have been a few floating posts since then, but the discussion is far outdated by now.