Change setTimeout length. Or Pause or something.

K

Knud

I have a frameset where a hidden frame reloads every 5 seconds and
collects data from the sever if there are any changes made in a
database. The hidden page updates Div fields on other frames with the
lastest information. This works great.

The problem I have is that when the hidden frame reloads it steals
focus from the main frame where a user can be entering information
into a form. (This is very annoying. As tabing through form elements
is stolen every 5 seconds.)

I looked at running a script to remember the element that had focus
and pass the focus back to that element from the hidden frame when the
reload is complete but that seems a messy way to do it and the cursur
seems to always go to the beginning of the form element not to where
you where typing.

I have the 5 second reload running in the Main frameset page.
----------------------------------
<script language="JavaScript1.2">
<!--
function keepUpdated()
{
setTimeout( "refresh()", 5*1000 );
}
function refresh()
{
window.updateStats.location.reload( false );
keepUpdated();
}
//-->
</script>

<frameset rows="29,*,0,20" onload="keepUpdated();">
<frame name="topMenu" target="middle" src="./frame_TopMenu.asp">
<frameset cols="172,*">
<frame name="left" src="frame_LeftMenu.asp" target="middle">
<frame name="middle" src="./login.asp" target="_self">
</frameset>
<frame name="updateStats" src="./frame_Hidden.asp">
<frame name="bottom" src="./frame_Bottom.asp">
</frameset>

----------------------------------
What I think would be a better way of handling the reload would be
when a data entry page is called to pass to the refresh function a new
timeout value of 5 minutes. Then when the data entry is complete (The
user submits a form) send the timeout value of 5 seconds again. (This
way the reload is supended for a while so you can enter data without
the reload stealing focus.)

I'm new to Javascript and not sure how I can set up a variable to do
this. Could someone show me some code on how to do this or another
solution to my problem would be great. Thanks.
 
R

Randy Webb

Knud wrote:

What I think would be a better way of handling the reload would be
when a data entry page is called to pass to the refresh function a new
timeout value of 5 minutes. Then when the data entry is complete (The
user submits a form) send the timeout value of 5 seconds again. (This
way the reload is supended for a while so you can enter data without
the reload stealing focus.)

Thats a possibility. But what happens if they leave the app for an hour,
something gets changed that they are working on, yet it doesn't get updated?
I'm new to Javascript and not sure how I can set up a variable to do
this. Could someone show me some code on how to do this or another
solution to my problem would be great. Thanks.

Look into an HTTPRequestObject
http://jibbering.com/2002/4/httprequest.html

Its IE/Mozilla only but I believe it can do what you want (timed
updates) without stealing focus.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top