Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I want my site to block access to visitors that are using outdated browsers such as IE6 and IE7 etc.

I am looking for a script that I can use to block certain browsers accessing my site

share|improve this question
1  
May I ask why do you want to block them?! –  Omne Sep 19 '12 at 14:35
1  
The only real reason for not supporting (different from "blocking") older browsers is that your web project not only makes use of, but requires the latest and most advanced browser to function. Is that your scenario? If so, what scripting environment are you using? –  msanford Sep 19 '12 at 15:23
2  
I'm blocking them because I can't be bothered supporting them. It might even be technically feasible to support even IE6 but as I'm a solo developer have to choose new features vs legacy browser support and chose the first. Only site access stats can tell me I'm wrong :) –  L. De Leo Sep 19 '12 at 15:41
1  
Hmm... but don't do that! IMO start with a simple design which supports older browsers too, then expand it for new technologies. believe me, you'll loose a lot with blocking older browsers, there are many people who still use them, people who never upgrade their default IE... if youo're website is live atm, your stats should confirm this. even websites created solely for new browsers have some level of support for older ones... –  Omne Sep 19 '12 at 15:48
2  
"better practices" and "blocking access to legacy browsers" - isn't that a contradiction?! –  w3d Sep 19 '12 at 21:17

1 Answer 1

You can detect older versions of Internet Explorer using the IE Conditional Comments feature. The following snippet when included in a web page will redirect versions older than IE 8 to a separate page -

<!--[if lt IE 8]>
<SCRIPT LANGUAGE="javascript">
location.href="legacy.html";
</SCRIPT>
<![endif]-->

You can also choose to hide the page's content by setting the container tag's display property style to none via JavaScript.

The browser can also be detected through server-side code.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.