whammy
09-21-2002, 05:22 PM
Hi gurus,
I made a "shoutbox" type application, but I'm trying to keep it all on one page instead of using frames (the framed version works though) -
The problem I'm running into is I'd like for the page to refresh in 60 seconds if noone types (this works great) - however once someone starts typing in the text field, I'd like to reset the refresh function, so that it won't refresh while someone is typing if they happen to be crossing that 60 second mark.
I tried referring to the function with the setTimeout() in it again onclick, and onkeypress, but in the first instance the original <body onload="refre****(60000)"> event still fires - and onkeypress makes it refresh numerous times.
How can I "kill" the first setTimeout() called, and reset it? Below is the relevant code:
<html>
<head>
<script language="JavaScript" type="text/javascript">
<!--
function refre****(rt){
setTimeout("window.location='shoutbox.asp'",rt);
}
//-->
</script>
</head>
<body onload="document.shoutbox.message.focus(); refre****(60000)">
<div align="center">
<form name="shoutbox" action="shoutbox.asp" method="post">
<input type="text"
name="message"
size="16"
maxlength="70"
style="background-color: #999999"
/>
<input type="submit" value="->" "WHAT CAN I DO HERE?" /><br /><br />
</div>
</body>
</html>
Thanks in advance for any help.
I made a "shoutbox" type application, but I'm trying to keep it all on one page instead of using frames (the framed version works though) -
The problem I'm running into is I'd like for the page to refresh in 60 seconds if noone types (this works great) - however once someone starts typing in the text field, I'd like to reset the refresh function, so that it won't refresh while someone is typing if they happen to be crossing that 60 second mark.
I tried referring to the function with the setTimeout() in it again onclick, and onkeypress, but in the first instance the original <body onload="refre****(60000)"> event still fires - and onkeypress makes it refresh numerous times.
How can I "kill" the first setTimeout() called, and reset it? Below is the relevant code:
<html>
<head>
<script language="JavaScript" type="text/javascript">
<!--
function refre****(rt){
setTimeout("window.location='shoutbox.asp'",rt);
}
//-->
</script>
</head>
<body onload="document.shoutbox.message.focus(); refre****(60000)">
<div align="center">
<form name="shoutbox" action="shoutbox.asp" method="post">
<input type="text"
name="message"
size="16"
maxlength="70"
style="background-color: #999999"
/>
<input type="submit" value="->" "WHAT CAN I DO HERE?" /><br /><br />
</div>
</body>
</html>
Thanks in advance for any help.