First, we make sure that this browser is IE and has been tested once. If you have doubts about this, you can test it.
1. document. all
2 ,!! Window. ActiveXObject;
The usage is as follows:
If (document. all ){
Alert ("IE browser ");
} Else {
Alert ("non-IE browser ");
}
If (!! Window. ActiveXObject ){
Alert ("IE browser ");
} Else {
Alert ("non-IE browser ");
}
The following describes how to differentiate IE6, IE7, and IE8:
Var isIE = !! Window. ActiveXObject;
Var isIE6 = isIE &&! Window. XMLHttpRequest;
Var isIE8 = isIE &&!! Document.doc umentMode;
Var isIE7 = isIE &&! IsIE6 &&! IsIE8;
If (isIE ){
If (isIE6 ){
Alert ("ie6 ″);
} Else if (isIE8 ){
Alert ("ie8 ″);
} Else if (isIE7 ){
Alert ("ie7 ″);
}
}
First, we make sure that this browser is IE and has been tested once. If you have doubts about this, you can test it.
I am using it directly here. You can declare them as variables for use. It is said that Firefox will also add the document. all method in the future. Therefore, it is recommended to use the second method, which should be safer.