Solved

How to detect IE6 & display a special message

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…
The viewer will learn how to dynamically set the form action using jQuery.

760 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