7

Web アプリケーションの開発を終えたばかりで、Internet Explorer 8 以降をブロックしたいと考えています。これを達成するための最良の方法は何ですか?

IE6 をブロックする方法を見つけましたが、チュートリアル ( http://css-tricks.com/ie-6-blocker-script/ ) は 2008 年のもので、少し古くなっているように感じます。IE 7 と 8 もブロックしたい...

このサイトは、多くの Backbone.js を使用して CodeIgniter で構築されています。

誰かがアイデアを持っていれば、彼らは高く評価されます。

ありがとう!

アップデート

申し訳ありませんが、詳細情報: はい、それらをブロックします。メッセージを表示し、ページのスタイルを設定して、「申し訳ありませんが、Web ブラウザーではない Internet Explorer を使用しています。ここから CHROME をダウンロードしてください」と言うことができるようにします。

4

7 に答える 7

10

CSS と条件付きコメントでそれを行います。

<head>
    <!--[if IE lte 8]>
    <link rel="stylehseet" type="text/css" href="blockIE.css" />
    <[endif]-->
</head> 
<body>
    <div class="yourcontent">
        ...
    </div>
    <div class="notification">
        <h1>Sorry, we don't support your old browsers</h1>
    </div>
</body>

CSS:

body * { display: none }
.notification { display: block; }
于 2013-03-07T15:53:44.483 に答える
8

CodeIgniter、 https: //www.codeigniter.com/user_guide/libraries/user_agent.html でも実行でき ます。

何かのようなもの:

$this->load->library('user_agent');
if ($this->agent->browser() == 'Internet Explorer' && $this->agent->version() <= 8){
    //Redirect or show error
}

(ここでも回答: Code Igniter - ブラウザを検出する最良の方法)

于 2013-03-07T15:50:53.193 に答える
2

これにより、IE 8 以下のブラウザーがチェックされます。< head > で使用されます

<!--[if lte IE 8]>
    <meta http-equiv="refresh" content="0; url=http://www.google.com" />
    <script type="text/javascript">
        window.top.location = 'http://www.google.com';
    </script>
<![endif]-->
于 2013-03-07T15:55:56.513 に答える
0

jQueryを使用してそれを行うことができます:

//if its internet explorer...
if(jQuery.browser.msie){
     //getting the version
     if($.browser.version < 8){
         //do whatever
     }
}

より詳しい情報。

アップデート

コメントが指摘しているように、この機能はお勧めしません。これを確認する必要があります: jQuery.supportを使用してIE7とIE8を検出する方法

更新2

ここで指摘されているように、PHPでもそれを行うことができます。

于 2013-03-07T15:48:28.457 に答える
0

htaccess を使用して MSIE をブロックできます

<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase / 

RewriteCond %{HTTP_USER_AGENT} MSIE 
RewriteCond %{REQUEST_FILENAME} !ban_ie.php 
RewriteRule .* /ban_ie.php [L] 

RewriteCond %{HTTP_USER_AGENT} MSIE 
RewriteCond %{REQUEST_FILENAME} !ban_ie.php 
RewriteRule .* /ban_ie.php [L] 
</IfModule>

またはphpスクリプトを使用できます

<?php
ob_start();
?>
<html>
<head>
<style type="text/css">
* {
margin:0;
padding:0;
height:100%;
}
#mydiv {
position:absolute;
width:400px;
height:90px;
text-align:center;
top:50%;
left:50%;
margin-top:-40px;
margin-left:-200px;
border:solid 2px red;
padding-top:30px;
background:#ffff00;
font-weight:bold;
}
</style>
</head>
<body>
<div id="mydiv">
<?php
$browser = $_SERVER['HTTP_USER_AGENT'];
if(strstr($browser, "MSIE"))
{
   echo"BG: Свалете си Mozilla Firefox за да влезнете в сайта  EN: Download Mozilla Firefox to enter website <br /> <b><a href='http://www.mozilla.com/en-US/firefox/'>Mozilla Firefox</a></b>";
}
elseif (strstr($browser, "Opera"))
{
   echo"Свалете си мозилла <br /> <b><a href='http://www.mozilla.com/en-US/firefox/'>Mozilla Firefox</a></b>";
}
else {
   header("Location: http://muonline-bg.eu/");
}
?>
</div>
</body>
</html>
于 2014-11-11T08:48:00.057 に答える
0
<!--[if lt IE 9]>
    <!-- Some div saying sorry or calling js function or whatever -->
<![endif]-->
<!--[if lte IE 8]>
    <!-- Some div saying sorry or calling js function or whatever -->
<![endif]-->
于 2013-03-07T15:53:56.310 に答える