AJAX初级聊天室代码

2019-09-14 07:25:19王旭

}
function nextChat(){
    if(chatStart && chatStart < chats.length && chats.length > 1){
        if(chatStart == 0.5){
            chatStart = 1
        }else if(chatStart == chats.length - 1){
            chatStart = chats.length - 1
        }else{
            chatStart += 1
        }
        getName("inputs").value = chats[chatStart]
    }
    getId("loadifo").innerHTML = chatStart+","+chats.length
}


主ASP程序文件:请保存为chat.asp
程序代码 程序代码
<%@LANGUAGE="JAVASCRIPT" CODEPAGE="936"%><%
    Session.CodePage = 936
    Response.ContentType = "application/xml"
    Response.Expires = 0
%><%
function repla(str){
    str = str.replace(/&/g, "&");
    str = str.replace(/>/g, ">");
    str = str.replace(/</g, "<");
    str = str.replace(/"/g, """);
    str = str.replace(/'/g, "'");
    return str;
}

var useIp = Request.ServerVariables("REMOTE_ADDR")
if(!Application("counts")){
    Application("counts") = 0
}
if(Request("cont").Count != 0){
    Application.Lock()
        if(Application("counts") < 21){        
            Application("counts") += 1
        }else if(Application("counts") >= 21){
            Application("counts") = 1
        }
        var Cnum = Application("counts")
        var Msgs = repla(Server.HTMLEncode(Request("cont")))
        Application("ips" + Cnum) = useIp +""
        Application("msgs" + Cnum) = Msgs +""
        if(Request("named").Count != 0){
            var names = Request("named")
        }else{
            var names = ""