Определить версию IE (до v9) в JavaScript

Я хочу, чтобы пользователи нашего веб-сайта отображали страницу с ошибкой, если они используют версиюInternet Explorer до v9. Это просто не стоит нашего времени и денег, чтобы поддержатьIE pre-v9, Пользователи всех других браузеров, отличных от IE, в порядке и не должны быть отклонены. Вот предложенный код:

if(navigator.appName.indexOf("Internet Explorer")!=-1){     //yeah, he's using IE
    var badBrowser=(
        navigator.appVersion.indexOf("MSIE 9")==-1 &&   //v9 is ok
        navigator.appVersion.indexOf("MSIE 1")==-1  //v10, 11, 12, etc. is fine too
    );

    if(badBrowser){
        // navigate to error page
    }
}

Этот код поможет?

Чтобы избежать нескольких комментариев, которые, вероятно, будут встречаться у меня:

Yes, I know that users can forge their useragent string. I'm not concerned. Yes, I know that programming pros prefer sniffing out feature-support instead of browser-type but I don't feel this approach makes sense in this case. I already know that all (relevant) non-IE browsers support the features that I need and that all pre-v9 IE browsers don't. Checking feature by feature throughout the site would be a waste. Yes, I know that someone trying to access the site using IE v1 (or >= 20) wouldn't get 'badBrowser' set to true and the warning page wouldn't be displayed properly. That's a risk we're willing to take. Yes, I know that Microsoft has "conditional comments" that can be used for precise browser version detection. IE no longer supports conditional comments as of IE 10, rendering this approach absolutely useless.

Любые другие очевидные проблемы, о которых нужно знать?

Ответы на вопрос(29)

Ваш ответ на вопрос