A lot of the previous chat room program Oh, only use two files Oh. Let me see the first HTML file.
<style>*{font:9pt Song Body;line-height:1.7}</style>
<script>
var xmldom = document.createelement ("xml");
Xmldom.onreadystatechange=function ()
{
if (xmldom.readystate = = "interactive")
{
var chatinfo = Xmldom.selectnodes ("//chat");
for (Var c=0; c<chatinfo.length; C + +)
{
var from = Chatinfo[c].selectsinglenode ("sender");
var to = Chatinfo[c].selectsinglenode ("receiver");
var Say = Chatinfo[c].selectsinglenode ("Speak");
var div = document.createelement ("div");
Div.appendchild (Text (From.text, From.getattribute ("Color"), true);
Div.appendchild (Text ("right"));
Div.appendchild (Text (To.text, To.getattribute ("Color"), true);
Div.appendchild (Text ("said:"));
Div.appendchild (Text (Say.text, Say.getattribute ("color"));
var Shijian = Text ("[" + (New Date parseint (Chatinfo[c].getattribute ("Time"))). toLocaleString () + "]", "#abcdef");
ShiJian.style.fontSize = "3mm";
Div.appendchild (Shijian);
Document.body.firstChild.appendChild (DIV);
Div.scrollintoview ();
}
SetTimeout ("Show ()", 2000);
}
}
function text (text, color, clicked)
{
var txtnode = document.createTextNode (text);
if (color)
{
var fontnode = document.createelement ("Font");
Fontnode.color=color;
if (clicked)
{
FontNode.style.textDecoration = "Underline";
FontNode.style.cursor = "pointer";
Fontnode.onclick = function ()
{
document.getElementById ("ToName"). Value = text;
document.getElementById ("Chatinput"). focus ();
}
}
Fontnode.appendchild (Txtnode);
}
Return Color?fontnode:txtnode
}
Function Show ()
{
var SendText;
var myinput = document.getElementById ("Chatinput");
if (myinput.disabled)
{
var from = document.getElementById ("MyName"). Value;
if (! From) from = "Anonymous";
var to = document.getElementById ("ToName"). Value;
if (! To) to = "Everyone";
var fromcolor = document.getElementById ("MyColor"). Value;
var tocolor = document.getElementById ("Sendcolor"). Value;
var chatcolor = document.getElementById ("Saycolor"). Value;
SendText = "?" + Escape ([From,fromcolor,to,tocolor,document.getelementbyid ("Chatinput"). Value,chatcolor].join ("B") );
myinput.disabled = 0;
Myinput.value = "";
Myinput.focus ();
}
Xmldom.load ("post.asp" +) + (SendText? SendText: ""));
}
function SetColor (Colorid)
{
var Clrsel = document.getElementById (Colorid);
ClrSel.options.selectedIndex = parseint (Math.random () * clrSel.options.length);
}
onload = function ()
{
SetColor ("MyColor");
SetColor ("Saycolor");
SetColor ("Sendcolor");
if (!name) name = prompt ("Please enter your name:", "Anonymous");
document.getElementById ("MyName"). Value = name?name: "Anonymous";
document.getElementById ("Chatinput"). focus ();
Show ();
}
</script>
<input id= "myname" size= "value=" I ><select id= "MyColor" >
<option value= "#000000" style= "Background-color:black;color:white" > #000000 </option>
<option value= "#ff0000" style= "Background-color: #ff0000" > #ff0000 </option>
<option value= "#008000" style= "Background-color: #008000" > #008000 </option>
<option value= "#0000ff" style= "Background-color: #0000ff" > #0000ff </option>
<option value= "#800080" style= "Background-color: #800080" > #800080 </option>
<option value= "#008080" style= "Background-color: #008080" > #008080 </option>
<option value= "#808000" style= "Background-color: #808000" > #808000 </option>
</select> to <input id= "ToName" size= "value=" ><select "id=" >
<option value= "#000000" style= "Background-color:black;color:white" > #000000 </option>
<option value= "#ff0000" style= "Background-color: #ff0000" > #ff0000 </option>
<option value= "#008000" style= "Background-color: #008000" > #008000 </option>
<option value= "#0000ff" style= "Background-color: #0000ff" > #0000ff </option>
<option value= "#800080" style= "Background-color: #800080" > #800080 </option>
<option value= "#008080" style= "Background-color: #008080" > #008080 </option>
<option value= "#808000" style= "Background-color: #808000" > #808000 </option>
</select> said: <select id= "Saycolor" >
<option value= "#000000" style= "Background-color:black;color:white" > #000000 </option>
<option value= "#ff0000" style= "Background-color: #ff0000" > #ff0000 </option>
<option value= "#008000" style= "Background-color: #008000" > #008000 </option>
<option value= "#0000ff" style= "Background-color: #0000ff" > #0000ff </option>
<option value= "#800080" style= "Background-color: #800080" > #800080 </option>
<option value= "#008080" style= "Background-color: #008080" > #008080 </option>
<option value= "#808000" style= "Background-color: #808000" > #808000 </option>
</select>
<input style= "width:100%" onkeypress= "if (value&&event.keycode==13) disabled=1" id= "ChatInput" ></ Body>