We know IE browser will carry MSIE this way, so that is good to judge.
The typical useragent of IE versions are as follows:
mozilla/4.0 (compatible; MSIE 10.0; Windows NT 6.0)
mozilla/4.0 (compatible; MSIE 9.0; Windows NT 6.0)
mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0)
mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.2)
mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)
mozilla/4.0 (compatible; MSIE 5.0; Windows NT)
Where the version number is the number after the MSIE.
With ActiveXObject, only IE supports the creation of ActiveX controls, so she has something that other browsers do not have, that is, the ActiveXObject function. As long as you judge the Window object exists ActiveXObject function, you can clearly determine the current browser is IE
code is as follows |
copy code |
(function () { var isie=!! Window. ActiveXObject; var Isie6=isie&&!window. XMLHttpRequest; if (Isie) {if (isIE6) {alert (' You are using a low version browser, we recommend that you use Google Chrome browser, Firefox firefox browser, or IE7 version of the browser to ensure you have better access! ');}} }) (); |