By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,747 Members | 1,594 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,747 IT Pros & Developers. It's quick & easy.

Change setTimeout length. Or Pause or something.

P: n/a
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.
Jul 23 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Knud wrote:

<--snip-->
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.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq
Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.