简体   繁体   English

禁止Internet Explorer 6.0浏览器打开网站?

[英]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. 由于某些安全原因,我正在开发一个我不允许在IE 6.0浏览器中打开的网站。 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 ? 我知道每个浏览器都有一个唯一的标头信息,当我们请求网页时会发送该信息,因此我可以阻止我的网站在IE 6.0或任何使用javascript,php或其他任何浏览器的网站中打开吗?

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

Seriously though, you can use the IE conditional comments à la HTML5 Boilerplate : 认真地说,您可以使用IE条件注释à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">
  ...

For IE it's easy because Microsoft added special tags that you can detect what IE version. 对于IE而言,这很容易,因为Microsoft添加了特殊标记,您可以检测到哪个IE版本。 It's much more reliable than trying to use the User-Agent header. 这比尝试使用User-Agent标头要可靠得多。 Something like this should work (in the head of your HTML) 这样的事情应该起作用(在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 ;-) 显然,将链接替换为您自己的网站,并且可能更巧妙一些;-)

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. 未经修改的Internet Explorer 6版本将运行此代码,而其他浏览器则不会。 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. 请向我们详细说明您要在这里做什么。

Some simple PHP that you can include on every page to catch MSIE users: 您可以在每个页面上包含一些简单的PHP来捕获MSIE用户:

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. 您还可以通过许多其他更复杂,更全面的方法来完成此操作。

Sure, check this out (CGI method, PHP method, JS method) 当然,请检查一下 (CGI方法,PHP方法,JS方法)
PHP: 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: 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";
}
// -->

If you really want to do this... 如果您真的想这样做...

In PHP: 在PHP中:

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

  exit();
}

Update AND teach them a lesson at the same time: 更新并同时教他们一个教训:

http://ie6update.com/ 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. 但这可能会欺骗其中的一些人摆脱被称为IE6的邪恶祸害。 Darn Microsoft! 该死的微软!

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. 出于安全原因,标头中的某个UA太容易被欺骗以至于无法使用它,并且如果有人想在不允许使用的应用程序上使用IE6,则可以使用一个简单的代理来完成它,使应用程序认为那是IE8。

That said, you can easily get it done in PHP using the get_browser function. 也就是说,您可以使用get_browser函数在PHP中轻松完成此操作。

See http://php.net/get_browser http://php.net/get_browser

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. 有一个专门的类,在其中跟踪所有浏览器和设备的所有USER_AGENTS,创建它们的数据库并将其集成到您的工作Session例程中。 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. 每次用户进入时,确定其用户代理信息[类型,名称和版本],然后将数据传递到您的Display例程,该例程应确定要打印的内容和设计模板。 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! 这样,您可以建立一个SEO友好,用户友好,整洁且易于组织的网站[= developer-friendly]-ALL in ONE,这是在当今的Internet上偶然发现的一件非常罕见的事情...所以,做对了!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM