一个老掉牙的问题,不曾遇到就不会知道会这样,,,,,,
document.getElementById("showUserError").innerHTML = "<font color=blue> 检验中...请稍候!</font>";
var webFileUrl = "";
webFileUrl = window.frames["ifr2"].location.href="Verify_Name.aspx?user=" + User;
var result = "";
//开始取值过程
//var xmlHttp = new ActiveXObject("MSXML2.XMLHTTP");
var xmlHttp ;//= new ActiveXObject("MSXML2.XMLHTTP");
/*@cc_on
@if (@_jscript_version >= 5)
try {
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlHttp = false;
}
}
@else
xmlHttp = false;
@end @*/
if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
try {
xmlHttp = new XMLHttpRequest();
} catch (e) {
xmlHttp = false;
}
}
xmlHttp.open("POST", webFileUrl, false);
xmlHttp.send("");
result = xmlHttp.responseText;
if(result == "0")
{
document.getElementById("showUserError").innerHTML = "<img src='images/r.gif' border='0' /><font color=green> 该用户名可以使用</font>";
return true;
}
else if(result == "1")
{
document.getElementById("showUserError").innerHTML = "<img src='images/x.gif' border='0' /><font color=red> 用户名已经存在,请选用其他用户名!</font>";
return false;
}
else
{
document.getElementById("showUserError").innerHTML = "<img src='images/x.gif' border='0' /><font color=red> 系统超时!</font>";
return false;
}
创建兼容的xmlHTTP 这个摘自 http://hi.baidu.com/vsworld/blog/item/655bddc4171e55cd38db4964.html
/*@cc_on
@if (@_jscript_version >= 5)
try {
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlHttp = false;
}
}
@else
xmlHttp = false;
@end @*/
if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
try {
xmlHttp = new XMLHttpRequest();
} catch (e) {
xmlHttp = false;
}
}
另一个要注意的地方xmlHttp.send("");如果写成xmlHttp.send(); 或 xmlHttp.send(null);FireFox都不行