检测是否有任何类型的IE(MSIE) [英] Detect if any kind of IE (MSIE)

查看:74
本文介绍了检测是否有任何类型的IE(MSIE)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不想让用户使用Microsoft Internetexplorer(任何版本)访问我的网站。

I dont want to allow users to access my site with Microsoft Internetexplorer (ANY VERSION).

我目前发现的是检测它是否是它低于或等于10版。

What I´ve found so far was to detect if it´s lower or equal version 10.

一个非常令人讨厌的事情:Internetexplorer> v10不承认自己是一名InternetExplorer。

A very annoing thing: Internetexplorer >v10 doesn´t admit to be a InternetExplorer.

到目前为止我找到并尝试过:

What i´ve found and tried so far:

if(navigator.appVersion.indexOf("MSIE")!=-1){
alert("You use IE. That´s no good.");
}

if ( $.browser.msie ) {
alert( $.browser.version );
}

http://msdn.microsoft.com /en-us/library/ie/ms537509%28v=vs.85%29.aspx

我会使用任何解决方案,如果它是在javascript中, jquery或php,如果有的话。

I would use any solution if it is in javascript, jquery or php if there is one.

推荐答案

这对我来说可以检测任何版本的IE 5-11(Internet Explorer )(2014年8月5日)

This works for me to detect any Version of the IE 5-11 (Internet Explorer) (Aug/05/2014):

if (navigator.appName == 'Microsoft Internet Explorer' ||  !!(navigator.userAgent.match(/Trident/) || navigator.userAgent.match(/rv:11/)) || (typeof $.browser !== "undefined" && $.browser.msie == 1))
{
  alert("Please dont use IE.");
}

这篇关于检测是否有任何类型的IE(MSIE)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆