Solved

How to detect IE6 & display a special message

Posted on 2008-10-26
5
4,089 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

696 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