Solved

How to detect IE6 & display a special message

Posted on 2008-10-26
5
4,085 Views
Last Modified: 2013-11-19
I need a little javascript that will detect for IE6 and then let me display a message telling them to upgrade their browser. It would be ideal to just direct them to a special page where I could explain the whole thing.

I need code I can drop into my page. If possible, this seems like a pretty good script:
http://www.quirksmode.org/js/detect.html
0
Comment
Question by:cmlawson
5 Comments
 
LVL 12

Accepted Solution

by:
jazzIIIlove earned 250 total points
ID: 22808451

<script type="text/javascript">
 

if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ //test for MSIE x.x;

 var ieversion=new Number(RegExp.$1) // capture x.x portion and store as a number

 if (ieversion>=8)

  document.write("Damn, You're using IE8 or above, use FireFox")

 else if (ieversion>=7)

  document.write("Damn, You're using IE7.x, use FireFox")

 else if (ieversion>=6)

  document.write("Damn, You're using IE6.x, use FireFox")

 else if (ieversion>=5)

  document.write("Damn, You're using IE5.x, use FireFox")

}

else

 document.write("lol")

</script>

Open in new window

0
 
LVL 2

Assisted Solution

by:quetzal22
quetzal22 earned 250 total points
ID: 22809291
try conditional comments:
http://www.quirksmode.org/css/condcom.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

 "http://www.w3.org/TR/html4/loose.dtd">
 

<html>

<head>

<title></title>

</head>

<body>

<!-- check if browser is LESS than or EQUAL TO IE 6 -->

<!--[if lte IE 6]>

Please upgrade

<![endif]-->

</body>

</html>

Open in new window

0
 
LVL 44

Expert Comment

by:scrathcyboy
ID: 22809599
"telling them to upgrade their browser."

As funny as the comments are above, in reality, you are living in a DREAM world.  If you worked for a corporation at $80K+ per year, and they said YOU WILL USE IE6 and nothing else, or you will WALK, then I bet you wouldn't walk.  THAT is the reality of corporate choices today.  Companies for the most part do not trust anything but IE6 right now, and you damn-well WILL use it or else.  I think 80% of companies still require their employees to use IE6, or IE7 if they are "enlightened".

So save the prejudice about IE6 worse than Firefox (which I agree with, BTW) for yourself.  The choice of a user's browser is UP TO THE USER -- just like your choice of a ("running") mate.  To do browser detects correctly, you just change the code in the background per the browser, and not proselytize.
0
 
LVL 12

Expert Comment

by:jazzIIIlove
ID: 22809699
<<To do browser detects correctly, you just change the code in the background per the browser, and <<not proselytize.

This is a nice approach...I mean it is not very wise to tell the user, upgrade it...I mean if i were a guest of such site, i would feel as if i were belittled...so, i would leave the site...Adapt your code to different browsers, so that the guests won't have problems...

Best regards...
0
 

Author Comment

by:cmlawson
ID: 22836160
scrathcyboy - don't be a douche. this is not a forum. it's a place for solutions. you wanna discuss stuff like this head on over to sitepoint or digitalforums....
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now