Javascript 如何检测用户是否正在使用IE,并告知他们站点没有';你不支持IE吗?

Javascript 如何检测用户是否正在使用IE,并告知他们站点没有';你不支持IE吗?,javascript,html,internet-explorer,Javascript,Html,Internet Explorer,我正在用Zepto创建一个网站,所以它不支持任何Internet Explorer版本 如何检测用户是否正在使用Internet Explorer并将其重定向到通知网站不支持IE的页面 我读过一些有条件的评论,但Internet Explorer 10不支持这些评论 谢谢。您永远无法确定,但一个简单的选择是查看用户代理(例如PHP) 另请查看此处:按如下方式设置文档: <!doctype html> <!--[if lt IE 7 ]> <html class="i

我正在用Zepto创建一个网站,所以它不支持任何Internet Explorer版本

如何检测用户是否正在使用Internet Explorer并将其重定向到通知网站不支持IE的页面

我读过一些有条件的评论,但Internet Explorer 10不支持这些评论


谢谢。

您永远无法确定,但一个简单的选择是查看用户代理(例如PHP)


另请查看此处:

按如下方式设置文档:

<!doctype html>
<!--[if lt IE 7 ]> <html class="ie6"> <![endif]-->
<!--[if IE 7 ]>    <html class="ie7"> <![endif]-->
<!--[if IE 8 ]>    <html class="ie8"> <![endif]-->
<!--[if IE 9 ]>    <html class="ie9"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html class=""> <!--<![endif]-->
<head>
然后,如何处理这些类取决于您是希望使用css显示/隐藏div,还是使用javascript重定向页面

Javascript:

(function ($) {
    "use strict";

    // Detecting IE
    var IE;
    if ($('html').is('.ie6, .ie7, .ie8, .ie9, .ie10')) {
        IE = true;
    }

    if (IE) {
        // redirect
       window.location.replace('http://www.myotherpage.com');
    } 

}(jQuery));
或CSS:

.ie6 .myDivClassName,
.ie7 .myDivClassName,
.ie8 .myDivClassName,
.ie9 .myDivClassName,
.ie10 .myDivClassName {
  display: block; 
}

取决于你想做的事情。

fWw,Zeto现在有一个。我不知道,所以现在它支持IE10。还没有,但是它可能在将来。谢谢,但是IE10怎么样?对不起,我在重新阅读你的问题的时候正在编辑我的答案…IE10你可以通过使用JavaScript片段找到,见上面。谢谢,但是我如何显示另一个页面来通知用户该网站不支持IE?window.location.replace重定向到另一个页面,或者只是让div只显示IE的消息。请参阅IE9,我使用如下内容:。但是我把这个div放在你建议IE10的函数中的什么地方呢?
.ie6 .myDivClassName,
.ie7 .myDivClassName,
.ie8 .myDivClassName,
.ie9 .myDivClassName,
.ie10 .myDivClassName {
  display: block; 
}