Checking if DOM object is still valid

Discussion in 'Javascript' started by Robert Inder, Jul 28, 2006.

  1. Robert Inder

    Robert Inder Guest

    I'm having a problem having Javascript detect whether a document node
    is still valid.

    An intranet application (using IE6) has one window with a
    table of items which the user can select to examine in detail, one
    at a time, in another window.

    The Javascript that opens the window manipulates the "className" of
    the item's table cell...
    currentItemBlock = link.parentNode;
    currentItemBlock.className = "Current";

    so the style file makes it appear distinctive. Similarly, when
    the user selects a different item, or closes the detail window,
    it is changed again...

    if (currentItemBlock) {
    currentItemBlock.className = "Seen";
    }

    This all works nicely, except when the user closes the window
    containing the table of items. This destroys the document containing
    the table cell for the current item and in the process "poisons"
    currentItemBlock: any attempt to access it, such as

    alert("Constructor: " + currentItemBlock.constructor);

    causes a javascript error:

    The callee (server [not server application]) is not available and
    disappeared: all connections are invalid. The call did not execute.

    OK, I COULD make changes throughout the application so as to clear
    currentItemBlock if the relevant table-of-items window is closed.

    But what I'd really like to do is is to find out directly from
    the object in currentItemBlock.

    So how can I tell whether the object in currentItemBlock is actually
    safe to do anything with? Whether it is still part of a valid HTML
    document?

    Robert.

    --
    |_) _ |_ _ ._ |- | So what? It's easier for me, so I'll do it!
    | \(_)|_)(-'| |_ |
    deadspam.com is a spamtrap. | > > What's wrong with top posting?
    Use bcs.org.uk instead. | > It makes it hard to see comments in context.
     
    Robert Inder, Jul 28, 2006
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Elhanan
    Replies:
    3
    Views:
    398
    Thomas Hawtin
    Dec 15, 2005
  2. Replies:
    0
    Views:
    588
  3. John Salerno

    still a valid book?

    John Salerno, Feb 8, 2006, in forum: Python
    Replies:
    4
    Views:
    287
    John Salerno
    Feb 9, 2006
  4. juppie
    Replies:
    5
    Views:
    31,370
    juppie
    Aug 30, 2006
  5. copx
    Replies:
    7
    Views:
    389
    Mark McIntyre
    Mar 24, 2006
Loading...

Share This Page