Method 1: Recommended
// Create a Boolean variable
var xmlhttp = false;
// Check whether the IE browser is used
try{
// If the JS version is greater than 5
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
alert( "You are using Microsoft Internet Explorer.");
}catch(e){
// If not, use the old version of the ActiveX object
try{
// If you are using the IE browser
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP" );
alert("You are using Microsoft Internet Explorer.");
}catch(e){
// Use non-IE browser
xmlhttp = false;
}
}
// If you are using IE non-browser
if(!xmlhttp && typeof XMLHttpRequest != 'undefined'){
xmlhttp = new XMLHttpRequest();
alert("You are not using Microsoft Internet Explorer.");
}
Method 2:
var xmlhttp;
// If ActiveX objects are available, the IE browser must be used
(!window.ActiveXObject){
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}else{
//Use Javascript method to process
xmlhttp = new XMLHttpRequest();
}