Change setTimeout length. Or Pause or something.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Knud

    Change setTimeout length. Or Pause or something.

    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="JavaS cript1.2">
    <!--
    function keepUpdated()
    {
    setTimeout( "refresh()" , 5*1000 );
    }
    function refresh()
    {
    window.updateSt ats.location.re load( false );
    keepUpdated();
    }
    //-->
    </script>

    <frameset rows="29,*,0,20 " onload="keepUpd ated();">
    <frame name="topMenu" target="middle" src="./frame_TopMenu.a sp">
    <frameset cols="172,*">
    <frame name="left" src="frame_Left Menu.asp" target="middle" >
    <frame name="middle" src="./login.asp" target="_self">
    </frameset>
    <frame name="updateSta ts" src="./frame_Hidden.as p">
    <frame name="bottom" src="./frame_Bottom.as p">
    </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.
  • Randy Webb

    #2
    Re: Change setTimeout length. Or Pause or something.

    Knud wrote:

    <--snip-->
    [color=blue]
    > 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.)[/color]

    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?
    [color=blue]
    > 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.[/color]

    Look into an HTTPRequestObje ct


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

    --
    Randy
    comp.lang.javas cript FAQ - http://jibbering.com/faq

    Comment

    Working...