(Window. ActiveXObject) What does that mean?
Solution: To determine whether the browser supports ActiveX controls, if the browser supports ActiveX controls to leverage
var xml=new activexobject ("Microsoft.XMLHTTP"); Create XMLHttpRequest object (this is in previous versions of IE7); var xml=new can be used in newer versions of IE Create XMLHttpRequest objects in the form of ActiveXObject ("Msxml2.xmlhttp"), while Var xml=new xmlhttprequest () can be used in IE7 and non-IE browsers Creates a XMLHttpRequest object.
To create a XMLHttpRequest object, you must consider browser compatibility issues
Creating XMLHttpRequest Objects
By the way, when it comes to the difference, let's look at how to declare (use) it, and before sending the request and processing the response using the XMLHttpRequest object, we have to create a XMLHttpRequest object with JavaScript. (ie implements XMLHttpRequest as an ActiveX object, and other browsers [such as Firefox/safari/opear] implement it as a local JavaScript object). Let's take a look at how to use JavaScript specifically to create it:
Code:
Copy Code code as follows:
<script language= "javascript" type= "Text/javascript" >
<!--
var xmlhttp;
Creating XMLHttpRequest Objects
function Createxmlhttprequest () {
if (window. ActiveXObject) {//Determine if ActiveX controls are supported
XMLHTTP = new Activeobject ("Microsoft.XMLHTTP"); To create a XMLHttpRequest object by instantiating a new instance of ActiveXObject
}
else if (window. XMLHttpRequest) {//To determine whether to implement XMLHttpRequest as a local JavaScript object
XMLHTTP = new XMLHttpRequest (); Create an instance of the XMLHttpRequest (local JavaScript object)
}
}
-->
</script>
JS is used to distinguish between IE and other browsers and Ie6-8 methods.
1, document.all
2 、!! Window. ActiveXObject;
Use the following methods:
Copy Code code as follows:
if (document.all) {
Alert ("IE browser");
}else{
Alert ("Non IE browser");
}
if (!! Window. ActiveXObject) {
Alert ("IE browser");
}else{
Alert ("Non IE browser");
}
here are the ways to differentiate between IE6, IE7, and IE8:
Copy Code code as follows:
var isie=!! Window. ActiveXObject;
var Isie6=isie&&!window. XMLHttpRequest;
var isie8=isie&&!! Document.documentmode;
var isie7=isie&&!isie6&&!isie8;
if (Isie) {
if (isIE6) {
Alert ("Ie6″");
}else if (isIE8) {
Alert ("Ie8″");
}else if (isIE7) {
Alert ("Ie7″");
}
}
First of all we make sure that this browser is in the case of IE, conducted at a time of detection, if you have doubts about this, you can test.
I use this directly in judgment, and you can also declare them as variables to use first. It is said that Firefox will also join document.all this way, so it is recommended that the second method should be safer.