Here I would like to say is a relatively simple and easy to remember and use the method, recorded as follows.
Before, JS judged by using the browser's useragent field. By judging whether the UserAgent field contains a MSIE field to determine whether it is IE series browser, tried.
But after the IE11, Microsoft put its own IE revolution, IE11 inside of Useagent no msie words. The useragent of IE 11 is: "mozilla/5.0 (Windows NT 6.1; WOW64; trident/7.0; SLCC2;. NET CLR 2.0.50727;. NET CLR 3.5.30729;. NET CLR 3.0.30729; Media Center PC 6.0;. net4.0c;. net4.0e; Shuame; rv:11.0) Like Gecko ". Obviously before, according to MSIE way to judge, the IE11 is ineffective.
In fact, in addition to the UserAgent field, we can use the ActiveXObject object to judge.
A very simple function of judgment is as follows
function Isie () { if in window) returntrue; Else return false ;}
Some of the explanations are as follows:
Earlier versions of 1.IE, IE10 and below, window. ActiveXObject returns an object,!window. The ActiveXObject becomes false,!! Window. ActiveXObject is true, because yes or | | Symbol follow-up no longer need to judge, return true.
2.ie11, window. ActiveXObject returns Undefine,!window. ActiveXObject becomes true,!!. Window. The ActiveXObject becomes false and enters the window. ActiveXObject "In window determines that the judging condition returns true under IE11.
3. Other non-IE browsers, such as Chrome,firefox,window. ActiveXObject are all undefine,!!. Window. ActiveXObject are returned as false, while "window." ActiveXObject "In window also returns false, so the above judgment function returns false in non-IE browsers.
How to Judge Ie10 and how to use the version
varB_v =navigator.appversion;varIE6 = B_v.search (/msie 6/i)! =-1; varIE7 = B_v.search (/msie 7/i)! =-1;varIE8 = B_v.search (/msie 8/i)! =-1;varIE9 = B_v.search (/msie 9/i)! =-1;varIE10 = B_v.search (/msie 10/i)! =-1;if(IE6) {$ ("#myDis"). Hide (); }Else if(IE7) {$ ("#myDis"). Hide (); }Else if(IE8) {$ ("#myDis"). Hide (); }Else if(IE9) {$ ("#myDis"). Hide (); }Else if(IE10) {$ ("#myDis"). Hide (); }
How to tell the browser kernel