RIP IE6 – How to block Internet Explorer 6 from displaying web pages


As I stated in a previous post, Internet Explorer 6 is the nightmare of every web developer. It’s slow, it’s insecure and it’s stupid. Unfortunately, the fact that it’s more than 10 years old is not stopping some users from using it. Resolving the compatibility issues that usually arise sometimes is unworthy, so here is a little tweak to block the users using IE6 (or lower!):

In the <head> of the html file, include:

<!–[if lte IE 6]>
<script type=”text/javascript” src=”./js/rip_ie6.js”></script>
<![endif]–>
The content of the Javascript file is quite simple:

$(window).load(function() {
$(‘body’).css(“background-color”,”#414141″);

var message = ‘Sorry, but your browser (Internet Explorer 6) is not suported by this site. Please update to a newer version, or try an alternative browser:’;

var links = ‘<br><br><a href=”www.mozilla.com” title=”Mozilla Firefox”>Mozilla Firefox</a>’;
links += ‘<br><br><a href=”www.google.com/chrome” title=”Google Chrome”>Google Chrome</a>’;

$(‘body’).html(‘<div style=”width:600px;height:254px;background:white;margin:200px auto;padding: 20px;”><img src=”js/rip_ie6.png” alt=”" style=”float:left;margin-right:20px;”>’+message+links+’</div>’);

});

As you can see, I offer the user the possibility to download Firefox or Chrome, trying to minimize the damage suffered.
Of course, your web-page needs to have jQuery installed for the above code.

You can leave a response, or trackback from your own site.

Leave a Reply