Method 1: Recommended
// Create a Boolean variable
Var xmlhttp = false;
// Check whether IE browser is used
Try {
// If the JS version is later than 5
Xmlhttp = new ActiveXObject ("Msxml2.XMLHTTP ");
Alert ("You are using Microsoft Internet Explorer .");
} Catch (e ){
// If not, ActiveX objects of earlier versions are used.
Try {
// If you are using IE
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 an 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, you must use IE browser.
(! Window. ActiveXObject ){
Xmlhttp = new ActiveXObject ("Microsoft. XMLHTTP ");
} Else {
// Use Javascript for processing
Xmlhttp = new XMLHttpRequest ();
}