Method 1: Recommendation //Create a Boolean variable var xmlhttp = false; // Check whether you are using IE browser 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 ActiveX object try{ // If you are using IE browser xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); alert("You are using Microsoft Internet Explorer."); }catch(e){ // Use a 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 the ActiveX object is available, the IE browser must be used
(!window.ActiveXObject){
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}else{
// Use Javascript method to process
www.bkjia.com