I hate Internet Explorer.
There, I’ve said it. Perhaps it will help you to understand why I sat down tonight and decided to ex-out the worst of the bunch, Internet Explorer 5.5 (and below).
It pains me, physically pains me, to open up Internet Explorer after having designed something using Firefox as my primary browser. Granted, with IE7, things have improved and my design often (in a very general way) resembles what it should. However, taking steps backwards in the IE pedigree, things quickly go from worse to craptastic.
So, I decided, this is my site, and I should be able to set the standards for what “type” of people I want on here (you all, of course, are welcome anytime). I went looking for a script to help me do it, and couldn’t find one (to be honest, I didn’t look very hard). I found several that would pick out your browser type, and version. But the problem with these is the version number generally only goes as high as 4 – which all IE5+ browsers are.
My parameters were simple. If the person visiting the site had any browser other than Internet Explorer – they could come in. And to show I’m not a complete brute, I decided that those visiting with IE7, and IE6 could also come and play. Otherwise you get redirected to a page that informs the visitor that they might want to reconsider their choice of Web surfing app.
If you just want the files to make this happen, just right-click and select Save Link As…:
ifoldie.js oldie.html warning.jpg
Otherwise, lets put this together step by step.
Building the Script
First we need to open a blank text file (notepad or any plain text editor will do) to save as a Javascript file. Then, assign your variables:
<!--
var browser = navigator.appName
var ver = navigator.appVersion
var thestart = parseFloat(ver.indexOf("MSIE"))+1
var brow_ver = parseFloat(ver.substring(thestart+4,thestart+7))
The variables do the following:
- browser: Gets the browser type (IE, Netscape, etc.).
- ver: Gets the version string. A long string of info with various bits of goo in it.
- the start: We need this number for the next part – trust me.
- brow_ver: This is the IE version number (generally 5.5, 6.0 or 7.0), converted from a string into an integer.
Next, we need to create an IF conditional that decides whether the browser type is Internet Explore, and checks if the IE version is less than 6**. And if it is, we need to tell the browser to redirect to a pre-created HTML file instead of displaying the site.
if ((browser=="Microsoft Internet Explorer") && (brow_ver < 6))
{
window.location="http://www.yourdomain.com/redirectfile.html";
}
//-->
Implementing it
Then, simply make sure you have the redirectfile.html (or whatever page you wish to redirect the misguided and outdated user to) created. Save the text file as something.js (I like the name ifoldie.js, but that’s just me), and add the following line in between the <head></head> tags of your Web page:
<script type="text/javascript" src="http://www.yourdomain.com/ifoldie.js">
</script>
And there you have it.
As you can see from my redirect page, I’ve also added the user a convenient way to upgrade to a better browser.
** This can be changed to either be more diligent or less on who it allows access. If you want to redirect all users of IE6 and below, simply change this to 7. Likewise, it can be changed to 5.5 or 5 (or any lower number) to allow a greater range of access.
Add comments for any questions or suggestions.






awesome, thanks!
If I want to re-direct a user with 6 or lower i assume i just need to change if conditional to… brow_ver
Hey Jerry, yes, just change the “6″ to a “7″ and this will only allow IE browsers of version 7 or higher (should they decide to continue making the piece of junk) through.
Ryan,
Thanks great script!
What if I wanted to add Firefox to this script with a redirect to a different page?
Do i need to add another variable? and if so what would (ver.indexOf(“***”))+1 look like? and I’m assuming the if conditional would just need to be added with the ((browser=”Firefox”)&&(brow_ver
Hey Jerry, you could modify it to redirect for Firefox. The browser type will be listed as “Netscape” though, as Firefox/Mozilla is a branch of the original Netscape.
The tricky part is that this script cuts up the rather long Browser Version string to find out which actual version of IE you’re using. Check out this page. It has a script on it that displays your browser information.
If you’re using Firefox (as I am), you’ll see a string similar to:
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6
I don’t have the time to work out the math on it, but you just need to adjust the code in my script to cut that string up to give what Firefox version you’re using.
If you want to redirect ALL Firefox browsers, that’s quite easy. Just search the string for “Firefox” and if it returns true, redirect.
since about 85% of the world uses ie, its best to have two websites, one compatable with ie and one with firefox, I know it sucks, but its the most pro way.
Hey Erik, two Web sites isn’t really necessary – using IE’s conditional comments, adding alternative style sheets is a much better way to go about it. Just setting up secondary CSS rules to adjust for IE’s retardedness.
However – I still like the script, as it’s my little way of informing the world that they’re using a stupid browser.
Just what I have been looking for all these weeks – the dogs-danglies – simple and it works!!!
Ryan, the idea seems very silly to me. I like browsing the web with lynx (text based browser), what good is it for me to use firefox? Don’t force people to choose, just code to the right standards, prove that your site validates to wC3 standards and then let the browsers update to the international standards. For beilabs.com I have only one stylesheet, and zero hacks for IE, Safari or Firefox and it renders perfectly in all of them.
Let the users choose whatever browser they want on their own! If people want a crap web experience then that is their own choice.
Hey Valehru, didn’t know you headed back to Ireland.
I’m not forcing anyone to choose. You browsing in a text browser, someone browsing in Safari or Opera, or whatnot, are not going to notice anything different.
The only people affected on this site are people using an old outdated browser (IE5.5 or less) – which happens to break your site as well btw.
The problem with your solution is a single style sheet with no alternate stylesheet (or if absolutely needed, hacks) is not possible in a more complex design with lots of elements.
For a personal site (such as this, or any of my other sites) I can choose to do things like this redirect, however for clients sites, it most definitely will require that it look good in IE and all the best coding to standards in the world isn’t going to solve certain problems with IE6 – still the most widely used browser.
Not to look up your skirt, but you’re using an IE hack in your CSS for this very reason.
I do agree 100% that users should be allowed to choose whatever browser they want – but browser creators need to start more strictly adhering to standards. Once that happens (and it could be only a year or two away), life for your average CSS designer, will be a helluva lot easier.
Whoops, I had forgotten about that one. Must work on that CSS page a little more to get full compliance. Dammit.
Browser creators, looking at MS in particular, are never going to comply completely with all these standards. They way they see it is that they have the market share and that’s that.
Personally I despise IE with a passion, unfortunately in my line of work IE development is required. I once had a spec from a US client who demanded complete compliance from IE 5 and IE 6. Quite a difficult task. Fortunately with machines designed with IE 5 as a core browser are now reaching the end of their life cycle and are being phased out.
Exactly. I’m definitely not suggesting that people use this on the site’s of clients/businesses/etc. But for me, as I do both my own and “for hire” design, I just wanted this little script for my sites as they aren’t focused on business, and allow me to kindly kick people in the pants should they be using an out-dated browser.
And in regards to compliance, you gotta hand it to the swell folks on the Firefox development crew, as according to the figures on that link I gave in my last comment, they’re edging out IE one dissatisfied user at a time – and they do a reasonable job of maintaining compliance.
DONT WORK!!!
DOES WORK!!!
DON’T YELL!!!
I’m not sure this works, I’m trying to block IE6 and below browsers because I refuse to stoop to the level of using hacks and filters. More people are using IE7 and at least IE7 follows CSS standards better than it ever has.
I tested this script on a windows 2000 platform with IE6 and it didn’t redirect me to the page at all.
Hey Darren, I feel your pain man. I’ve not tested this using W2K, but if you copy and pasted the code above, I just noticed that in the first section of code – setting up the variables – the quotes are fancy quotes, and that will screw stuff up. Double check that.
An easy way to see if it’s working is to use http://ipinfo.info/netrenderer/index.php. Set it to IE 5.5 or less and put in daobydesign.com and you’ll see how it’s intended to work.
Ryan,
That’s EXACTLY it- it works! I didn’t even notice I had fancy quotes in the code, I’m glad you caught that.
Let me say that the code OFFICIALLY works for IE6 version browsers and below.
I recently learned CSS and found it to be a true pain in the @$$ that in order to make a site look good on IE6 – you have to use all sorts of hacks and bug fixes. I’m with you Ryan. CSS is a standard and browsers should try following those standards or be rejected. I’m sure there will be people who disagree because 36% still use IE6 but it sure would be nice to see everybody up to speed on web standard compliant browsers. This way developers can focus on creating great web sites without having to pull out their hair trying to find the right hack, bug fix, or filter.
ahha this is damend useful for me. I’m working on a site for a uni course. Complys fully with xhtml(strick)1.0 and fully with CSS3.0 (doesn’t comply with 2.0 because i use overflow-y: in my CSS)
My page looks like crap on IE6 though, so i was looking for a redirect to either warn them that the page won’t work, or just not allow access until they upgraded
Note: complys fully with the latest standards. Either way this piece of script is definatly going to be useuful to me.
I’m about to give up, no matter what I do I does not work
this is what I’m writing:
<!–
var browser = navigator.appName
var ver = navigator.appVersion
var thestart = parseFloat(ver.indexOf(”MSIE”))+1
var brow_ver = parseFloat(ver.substring(thestart+4,thestart+7))
if ((browser==”Microsoft Internet Explorer”) && (brow_ver
if I delete all the var that has something to do with the version and just leave the var browser works, but no matter how bad I would like to reject IE users I can’t so I just want to reject the IE6 and lower users… help!
Hey Nancy, it’s an issue with curvy quotes (”) – change them to straight (") quotes and you should be alright. Damn WP automatically changes them.
Optionally, simply copy and paste the code directly from the .JS file.
Thank you I’ll try tomorrow, I’m too tired now, I’ll let you know
It worked!!!!
thank you very much, do you mind if I use some of your text from your oldie.html?. I love what it says and everything and I sure want people to use Firefox instead on IE, but I think my client will find it “aggressive”, but I want to use the same concept.
@Nancy – glad it’s working. You are welcome to change any part of the script, text, or graphics to better suit your needs. I offer no copyright on any of it.
Thank you!!!!!!!!!!
right on .. IE, UGH!
Awesome script, when IE 6 (and older), simply fails to open strict DTD and latest WAI standard web sites. It’s good that Microsoft realised that their de facto standards does not work compared to W3C. IE7, and hopefully the upcoming IE8, works much better!
Hi Ryan, thanks for this script, much appreciated.. I did notice in your comments that you were saying a better option would be to redirect to a different stylesheet instead which is what I would prefer doing. Care to enlighten us on how that would be done?
Hey Kevin – check out the pingback between your comment and this one – wrote that sucker just for you
(and because this blog desperately needed to be updated!).
Thanks Ryan! checking it out now…
Thanks a lot. IE is crap ;/
Great script, simple but perfect for I needed. I check my stats and still see that IE is most commonly used…sucks to be a developer
Thank you!!! IE is the bane of my web existence. You have made my life so much easier!
Awesome! thank you so much. I no longer feel as though my face is going to implode out utter frustration. that’s a good feeling.
I found that I had to add an ‘=’ to the ‘brow_ver < 6′ to make it detect and redirect IE6.
if ((browser==”Microsoft Internet Explorer”) && (brow_ver <= 6))
Like that, in other words. Thanks a million for this script.
Thank you Ryan, super useful.
Hey Shan, cheers.
NOTE: For anyone looking for the ability to detect and redirect based on IE version, you might be interested in the latest post on this blog. It essentially does a more subtle (and easier to implement) IE detection using conditional comments.
Hello, great script, thanks!
How to insert code into WordPress blog ?
@Kiten: Simply throw it in between the HEAD tags usually found in the header.php file of your theme.
I mean is there any plugin for this?
Hi,
Is it possible to redirect certain people to a firefox ready page? and all others to a IE ready page? Seems these two are the main browsers in the UK.
Will this slow people down? and is it 100% relaible?
Thanks
@Kiten: None that I know of.
@Ian: You don’t need two different pages, you can just style things differently to fix inconsistencies between the browsers. Check out a post I’ve written on how to better handle redirection using conditional comments.
thank you – you save my live
Bah to ie! This was really helpful, thanks for releasing this great script!
Just want to let you know – love this script… Exactly what I was looking for (going to include in my new site). But I have to say, I agree with many people of having to create an alternate site for IE6, etc… So in my case I will be going that. Also, I agree with you – I HATE IE as well!
is there any javascript which can detect ie users and warn them to download firefox
Ah, you’re a lifesaver. Thanks so much.
It’s work! Thank your great script!
Man, this is bloody excellent! I love you! lol
Thank you so much for this, I spent ages trawling around the internet for this, and this is so simple – yet so great!
Anything to support the Bring Down IE6 campaign
>>http://www.facebook.com/home.php#/group.php?gid=51915907298
Thanks again
-Tom
Hi Ryan,
Thanks for this script. I’m having success with the redirect, but my problem is that IE6 just keeps redirecting and redirecting and the actual never loads. It’s like the script saw it was IE6, said “send it over to /ie6/” and once /ie6/ started to load, the script tried to send the user to /ie6/ again, thus never actually loading the page.
Any idea what might be going on? Many thanks.
YEAH this script rocks, now I can redirect to a page that will say something like: “We support the death of IE 6″. I hope IE 6 users gets the point . Thanks man you look great
Wow Ryan!! Thank you so much for the script. it works like charm. Great work! bye bye oldie!
I don’t get it…the script works fin in IE simulators, but it does not distinguish between IE6 and IE7. It redirects both-regardless. I only need IE6 and below redirected, not 7 and and above. I’m not sure why it is not working…=(
It’s me again…scratch that, it redirects ALL versions of IE…does not distinguish versions. Filters them all…as much as I hate Emperor Gates MicroCrap Exploder…some of the users of my site have this piece of junk as a browser, and I just want to weed out IE 6 and older-not all of them. Help please!!! I wonder if this is a Vista problem, another Microsoft Genius Product by the way…
HELP!!
@JQuest – please see the note I’ve added to the top of the post. It was a comment I left on here a while ago, but as it’s burried in the comments, I realized I need to draw more attention to it.
Basically, check this post. It’s a more efficient way of handling things.
Ryan-you are the man!!! A simple fix; why did I not think about that!!! Works like a charm now!! Thanks!!! I will follow the cause-IE is goin’ down…
Thank you, it helps me go through css position problem in explorer browser.
Thanks for your script, one of my sites http://jivova.ic.cz is now sending IE6 users to an advise page to get some newer stuff. I hated when, showing this site to people, I saw that wordpress just didn’t worked there. Maybe it’s WP issue, but I don’t seem to care.
Hello Ryan,
Just put this script on my website. Works fine. Cheers. Saved me having to redesign just for ie6 or lower. Amazingly, ie6 still has a 20% share of web users in 2010! its four years since ie7. The updates free people.
Thanks as well for explaining how to use the script in a clear way, a rare talent for a web developer!
Rock on.
THANK YOU THANK YOU THANK YOU!!!!!!!! I HATE Internet Explorer too. This is what i needed.
Thanks! I’ve been trying to find a script that actually worked all morning, and this is the only one I’ve found that does what I want. I set it to redirect IE6 and below to a different page on my site:
http://one9.us/browser-redirect.html
So far, seems to work perfectly. For anyone interested, I use http://ipinfo.info/netrenderer/index.php to check the pages.
Thanks again!
Awesome, am going to use this heaps. United we stand against corporate oppression.
Thank you very much, it is working. My site didn’t work at all in IE 4 5 and 6, so I needed this. From now on, i will probably use your code on most of the websites. Cheers
Finally a script that works.
I’ve tried so many and something always was going wrong.
GOOD JOB MAN
Thanks
Thank you so much! The sample files seem to be gone but your instructions are thorough and I implemented my first (well, your’s really!) javascript.
This requires so much work, i just use the below code in head section as far top possible.
/* */
works great for me
The code is here : http://wordpress.org/support/topic/382001
Just what i was looking for! Awesome! Thanks!
Hey man. Using your script – its ace! Just one thing, I’m getting feedback from some visitors who insist they’re using IE8 (the only IE I’ll permit) yet are still getting the redirect page. I can’t get to their machines to verify their claims but I’ve had this a couple of times so I’m inclined to think they’re telling the truth. Any ideas?
Hi Wolf — I recommend using this method as it allows you to target specific versions of IE a bit better.
It looks js. html and image files are gone…
Thank you so much. This is awesome. You really save my day.