Checking if DOM object is still valid

R

Robert Inder

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.
 

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,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top