大家不要嫌看着累哈
还有一个页面:chatmsg.aspx(无后台代码)
<script>
function out2(mfrom,mtime,mword)
{
Mstr=document.all.temp.value;
document.all.temp.value=Mstr + "<font color=#FF0000>"+mfrom+"</font>对你说:<br> <font color=#0000FF>"+mword+"</font><font color=#666666> ["+mtime+"]</font><br>";
document.all.message.innerHTML=parent.main.temp.value;
}
function out(mto,mtime,mword)
{
Mstr=document.all.temp.value;
document.all.temp.value=Mstr + "你对<font color=#0000FF>"+mto+"</font>说:<br> <font color=#0000FF>"+mword+"</font><font color=#666666> ["+mtime+"]</font><br>";
document.all.message.innerHTML=parent.main.temp.value;
}
</script>
</HEAD>
<body MS_POSITIONING="GridLayout">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td id="message" > </td></tr>
</table>
<input type="hidden" name="temp" >
还有一个页面:chatmsg.aspx(无后台代码)
<script>
function out2(mfrom,mtime,mword)
{
Mstr=document.all.temp.value;
document.all.temp.value=Mstr + "<font color=#FF0000>"+mfrom+"</font>对你说:<br> <font color=#0000FF>"+mword+"</font><font color=#666666> ["+mtime+"]</font><br>";
document.all.message.innerHTML=parent.main.temp.value;
}
function out(mto,mtime,mword)
{
Mstr=document.all.temp.value;
document.all.temp.value=Mstr + "你对<font color=#0000FF>"+mto+"</font>说:<br> <font color=#0000FF>"+mword+"</font><font color=#666666> ["+mtime+"]</font><br>";
document.all.message.innerHTML=parent.main.temp.value;
}
</script>
</HEAD>
<body MS_POSITIONING="GridLayout">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td id="message" > </td></tr>
</table>
<input type="hidden" name="temp" >
parent.frames["main"]iframe的name,id都加上看看
你把js代码的放在form表单之下就ok了!
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>say</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio 7.0">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312">
<link rel="stylesheet" href="inc/style.css" type="text/css">
<script>
function formsubmit(){
if (document.form1.mName.value==""){
alert("你想对谁说话?");
}else{
if(document.form1.mMessage.value=="")
{
alert("你想说什么?");
}else{
document.form1.action = "chat.aspx";
form1.submit();
document.form1.mMessage.value="";
document.form1.mMessage.focus();
}
}
}
function chkMsg(){
saymessage.location.href="chat.aspx";
loadmessage.location.href="chat2.aspx";
}
setInterval("chkMsg()",20000);
</script>
</HEAD>
<body MS_POSITIONING="GridLayout" bgcolor="#ffffff" text="#000000" oncontextmenu="return false" leftmargin="0" topmargin="0"> <table width="100%" border="0" cellspacing="0" cellpadding="0" height="100%" align="center">
<tr>
<td valign="center" class="borderon" height="30">MSG即时信息发送系统地籍信息系统中的一个重要组成部分。你可以用它和任何办公成员发送或留言即时消息。</td>
</tr>
<tr>
<td valign="top" align="middle" class="borderon"><iframe src="chatmsg.aspx" id="main" name="main" width="100%" height="100%" scrolling=no></iframe>
</td>
</tr>
<tr>
<form name="form1" method="post" target="saymessage" onkeydown="if(event.keyCode==13 )form1.s.click();"> <td height="10" class="borderon">
你对 <input type="hidden" name="mTo"> <input type="text" name="mName" size="6" readonly>
<input type="text" name="mMessage" size="28"> <input type="button" name="s" value="发言" onclick="formsubmit();" class="button2">
</td>
</form>
</tr>
<tr>
<td height="10" align="right" disabled class="borderon">软件开发:北京地星伟业科技有限公司
</td>
</tr>
</table>
<iframe name="saymessage" src="chat.aspx" width="0" height="0"></iframe>
<iframe name="loadmessage" src="chat2.aspx" width="0" height="0"></iframe>
</body>
</HTML>
<iframe name="saymessage" src="about:blank" width="0" height="0"></iframe>运行一下,二十秒后(执行延时函数后)看看是否还报错。
function chkMsg()
{
saymessage.location.href="chat.aspx";
loadmessage.location.href="chat2.aspx";
}
setInterval("chkMsg()",20000);
</script>