null or not an object using frames

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

    null or not an object using frames

    I have a site that is supposed to be 'real-time' which has a frameset
    of 2 rows (the bottom row is 1 pixel so essentially invisible to IE
    users which is the requirement for the product). The bottom frame
    refreshes using an http-refresh every 15 seconds. If new data is
    available on the server, it tells the top page to refresh. For checks
    and balances, the top frame has a form at the bottom of the page with a
    'clockBox'..whi ch is essentially a text box that gets updated every
    second so it looks like a timer. When the bottom frame refreshes, it
    waits 5 seconds then resets the top counter to 0. The top counter
    continues to count. If the top counter gets to 30 (which it never
    should unless the bottom frame gets stuck), it refreshes the bottom
    frame.

    My problem:
    When the top frame is taking too long to load, I get a javascript
    error:
    Error: 'window.parent. frames.body.cou tnerFomr.clockB ox' is null or not
    an object.

    Here's my code:

    <script language="javas cript">
    timer = setTimeout("set Counter()",8000 );
    function setCounter(){
    if (window.parent. frames["body"].counterForm.cl ockBox){
    window.parent.f rames["body"].counterForm.cl ockBox.value = 0;
    }
    }
    </script>

  • Stephen Chalmers

    #2
    Re: null or not an object using frames


    Phoenix <phoenixjenn@ya hoo.com> wrote in message
    news:1105466132 .503696.237550@ z14g2000cwz.goo glegroups.com.. .[color=blue]
    > I have a site that is supposed to be 'real-time' which has a frameset
    > of 2 rows (the bottom row is 1 pixel so essentially invisible to IE
    > users which is the requirement for the product). The bottom frame
    > refreshes using an http-refresh every 15 seconds. If new data is
    > available on the server, it tells the top page to refresh. For checks
    > and balances, the top frame has a form at the bottom of the page with a
    > 'clockBox'..whi ch is essentially a text box that gets updated every
    > second so it looks like a timer. When the bottom frame refreshes, it
    > waits 5 seconds then resets the top counter to 0. The top counter
    > continues to count. If the top counter gets to 30 (which it never
    > should unless the bottom frame gets stuck), it refreshes the bottom
    > frame.
    >
    > My problem:
    > When the top frame is taking too long to load, I get a javascript
    > error:
    > Error: 'window.parent. frames.body.cou tnerFomr.clockB ox' is null or not
    > an object.
    >
    > Here's my code:
    >
    > <script language="javas cript">
    > timer = setTimeout("set Counter()",8000 );
    > function setCounter(){
    > if (window.parent. frames["body"].counterForm.cl ockBox){
    > window.parent.f rames["body"].counterForm.cl ockBox.value = 0;
    > }
    > }
    > </script>
    >[/color]

    I suspect that's because window.parent.f rames["body"].counterForm.cl ockBox
    cannot be an object until window.parent.f rames["body"] is loaded.

    Instead of waiting a fixed time, it may be better to monitor continuously
    until the other frame's document is loaded.

    [Not tested]

    timer = setInterval("se tCounter()",500 );

    function setCounter()
    {
    if (window.parent. frames["body"] &&
    window.parent.f rames["body"].counterForm.cl ockBox)
    {
    clearInterval(t imer);
    window.parent.f rames["body"].counterForm.cl ockBox.value = 0;
    }
    }

    --
    S.C.


    Comment

    Working...