//验证用户的昵称
var xmlUser=new ActiveXObject( "microsoft.xmldom ");
var timer;
function chkUsername(username)
{
if(username== " ")
……
}
var info = document.getElementById( 'info ');
info.innerHTML= "检查用户名.... ";
xmlUser.load( "CheckUserAction.do?username= "+username);
LoadUserInfo();
}
function LoadUserInfo()
{
window.clearTimeout(timer);
if(xmlUser.readyState== "4 ")
{
……
}
else
{
……
}
}
请问一下这种情况下ie和firefox下如何兼容var xmlUser=new ActiveXObject( "microsoft.xmldom ");
谢谢!问题得到解决后马上结帖给分。
------解决方案--------------------
function createAJAXObj() {
var A;
var msxmlhttp = new Array(
'Msxml2.XMLHTTP.5.0 ',
'Msxml2.XMLHTTP.4.0 ',
'Msxml2.XMLHTTP.3.0 ',
'Msxml2.XMLHTTP ',
'Microsoft.XMLHTTP ');
for (var i = 0; i < msxmlhttp.length; i++) {
try {
A = new ActiveXObject(msxmlhttp[i]);
} catch (e) {
A = null;
}
}
if(!A && typeof XMLHttpRequest != "undefined ")
A = new XMLHttpRequest();
if (!A)
A = false;
return A;
}