Solved

How to detect IE6 & display a special message

Posted on 2008-10-26
5
4,087 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Preface In the first article: A Better Website Login System (http://www.experts-exchange.com/A_2902.html) I introduced the EE Collaborative Login System and its intended purpose. In this article I will discuss some of the design consideratio…
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 one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

813 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

15 Experts available now in Live!

Get 1:1 Help Now