收集的网上用的ajax之chat.js文件
2024-09-06 12:42:42
供稿:网友
var xmlHttp = false;
var ichatstate ;
try {
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e2) {
xmlHttp = false;
}
}
if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
xmlHttp = new XMLHttpRequest();
}
function sendmsg(){
var msgbody = escape(document.getElementById("msgbody").value);
var sendto = escape(document.getElementById("sendto").value);
var SendData = "msgbody=" + msgbody +"&sendto=" + sendto;
xmlHttp.open("POST","../ichat/sendmsg.asp",false);
xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlHttp.onreadystatechange = function sendok(){ if (xmlHttp.readyState == 4) { } }
xmlHttp.send(SendData);
document.getElementById("msgbody").value = "";
showmsg();
}
function hot_key() {
if (window.event.keyCode==13 && window.event.ctrlKey && document.getElementById("msgbody").value != ""){sendmsg();}
}
function exitchat(){
var url = "../ichat/online.asp?action=exit&pid=" +Math.random();
xmlHttp.open("GET", url, true);
xmlHttp.send(null);
}
function intochat(){
window.ionline.location.href="../ichat/online.asp?action=intochat";
showmsg();
}
function showonline(){
var url = "../ichat/online.asp?action=showonline&pid=" +Math.random();
xmlHttp.open("GET", url, true);
xmlHttp.send(null);
}
function showmsg(){
var url = "../ichat/getmsg.asp?pid=" +Math.random();
xmlHttp.open("GET", url, true);
xmlHttp.onreadystatechange = reloadX;
xmlHttp.send(null);
}