Vishwanath Dalvi
Vishwanath Dalvi

Reputation: 36611

disallow Internet explorer 6.0 browser from opening website?

I'm developing a website that I want to disallow opening in IE 6.0 Browser for some security reasons. I know every browser has a unique header information which sent when we request webpage so can I block my website opening in IE 6.0 or any browser using javascript,php or using anything ?

Upvotes: 1

Views: 1561

Answers (9)

Pelle
Pelle

Reputation: 6578

The real answer is: you can't. A certain UA in a header is too easy to spoof to use it for security reasons, and if somebody wants to use IE6 on an app that doesn't allow it, one could use a simple proxy to get it done, making the app think that it is IE8.

That said, you can easily get it done in PHP using the get_browser function.

See http://php.net/get_browser

Upvotes: 0

Michael Berkowski
Michael Berkowski

Reputation: 270607

If you really want to do this...

In PHP:

if (strpos($_SERVER['HTTP_USER_AGENT'], "MSIE 6")) {
  // exit or redirect or whatever...

  exit();
}

Upvotes: 1

bpeterson76
bpeterson76

Reputation: 12870

Update AND teach them a lesson at the same time:

http://ie6update.com/

Ok, so it doesn't block them completely out. But it might trick some of them from getting rid of the evil scourge known as IE6. Darn Microsoft!

Upvotes: 1

Gelmir
Gelmir

Reputation: 1857

I would say: DO IT RIGHT! Have a class dedicated to it, trace down all USER_AGENTS of all browsers and devices out there, create a database of them and integrate it to your working Session routine. Everytime user comes in, determine his User-agent information [type, name and version] and then pass the data to your Display routines which should determine what content and design templates to print. This way, you can build a web site which is SEO-friendly, user-friendly, tidy and easy to organize [=developer-friendly] - ALL IN ONE, which is a VERY RARE THING to stumble upon in todays Internet... So, DO IT RIGHT!

Upvotes: 0

rsp
rsp

Reputation: 111336

<!--[if (gt IE 6)|!(IE)]><!--> <html> Entire website? </html> <!--<![endif]-->

Seriously though, you can use the IE conditional comments à la HTML5 Boilerplate:

<!doctype html>  
<!--[if lt IE 7 ]> <html lang="en-us" class="no-js ie6"> <![endif]-->
<!--[if IE 7 ]>    <html lang="en-us" class="no-js ie7"> <![endif]-->
<!--[if IE 8 ]>    <html lang="en-us" class="no-js ie8"> <![endif]-->
<!--[if IE 9 ]>    <html lang="en-us" class="no-js ie9"> <![endif]-->   
<!--[if (gt IE 9)|!(IE)]><!--> <html lang="en-us" class="no-js"> <!--<![endif]-->
<head>
  <meta http-equiv="X-UA-Compatible" content="IE=Edge;chrome=1" >
  <meta charset="utf-8">
  ...

Upvotes: 4

Jason MacLean
Jason MacLean

Reputation: 513

Some simple PHP that you can include on every page to catch MSIE users:

if(preg_match('/MSIE/i',$_SERVER['HTTP_USER_AGENT'])){
   die('Your browser is not allowed');
}

There are many other more complicated and comprehensive ways you can accomplish this aswell.

Upvotes: 2

Cfreak
Cfreak

Reputation: 19309

For IE it's easy because Microsoft added special tags that you can detect what IE version. It's much more reliable than trying to use the User-Agent header. Something like this should work (in the head of your HTML)

<!--[if lte IE 6]>
<meta http-equiv="refresh" content="0;url=http://yoursite.com/ie6_is_a_steaming_pile.html">
<[endif]-->

Obviously replace the link with your own site and probably something more tactful ;-)

Upvotes: 4

The Surrican
The Surrican

Reputation: 29866

you can use conditional comments like this.

<!--[if IE 6]>
Special instructions for IE 6 here
<![endif]-->

an unmodified version of internet explorer 6 will run this code, other browser will not. however i don't know if this satisfies your security concern. everything can be faked.

you can also check the header information but its the same problem...

please tell us more about what you are trying to do here.

Upvotes: 3

mailo
mailo

Reputation: 2611

Sure, check this out (CGI method, PHP method, JS method)
PHP:

    <?php
   if (eregi("MSIE",getenv("HTTP_USER_AGENT")) ||
       eregi("Internet Explorer",getenv("HTTP_USER_AGENT"))) {
    Header("Location: http://www.domain.com/ie_reject.html");
    exit;
   }
?>

JS:

<!--
if (navigator.appName == "Microsoft Internet Explorer") {
        document.location = "http://www.domain.com/ie_reject.shtml"; 
} else { 
        document.location = "http://www.domain.com/realhomepage.html";
}
// -->

Upvotes: 1

Related Questions