【开源中国 APP 全新上线】“动弹” 回归、集成大模型对话、畅读技术报告”
function Ajax(){
var xmlHttp=null;
try{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();}
catch (e){
// Internet Explorer
try{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}
catch (e){
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}}
return xmlHttp;
}
function send(){
xmlHttp=Ajax()
if (xmlHttp==null){
alert ("您的浏览器不支持AJAX!");
return;}
var url="chat.php";
xmlHttp.onreadystatechange=change;
xmlHttp.open("POST",url,true);
data=gatdata();
thing="input="+document.getElementById("input").value+"&name="+document.getElementById("name").value+"&time="+data;
xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
xmlHttp.send(thing);
}
function change(){
if(xmlHttp.readyState==4){
if(xmlHttp.status==200){
mes=xmlHttp.responseText;
document.getElementById("show").value=mes;
}}
}
function sends(){
xmlHttp=Ajax()
if (xmlHttp==null){
alert ("您的浏览器不支持AJAX!");
return;}
var url="chat.php";
xmlHttp.onreadystatechange=change;
xmlHttp.open("POST",url,true);
xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
xmlHttp.send(null);
setTimeout('sends()',2000);
}
function gatdata(){
var day=new Date()
y=day.getFullYear();
if(y<1900){y=y+1900;}
mm=day.getMonth();
d=day.getDate();
h=day.getHours();
m=day.getMinutes();
s=day.getSeconds();
return y+"-"+mm+"-"+d+" "+h+":"+m+":"+s;
}
function check(){
txt=document.getElementById("input").value.replace(/(^s*)|(s*$)/g, "");
txtt=document.getElementById("name").value.replace(/(^s*)|(s*$)/g, "");
if(txtt.length == 0){
alert("姓名不能为空!");
document.getElementById("input").value="";
document.getElementById("input").focus();}
else if(txt.length == 0){
alert("留言不能为空!");
document.getElementById("input").value="";
document.getElementById("input").focus();}
else{
send();
document.getElementById("input").value="";
document.getElementById("input").focus();
}
}
这是聊天室的核心代码 在IE8 和火狐下可以正常显示出数据库中的内容,在IE6,傲游下没有响应,不显示数据。。。怎么兼容呀。急需!!!
引用来自“rutine”的答案