Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Checking if DOM object is still valid

Reply
Thread Tools

Checking if DOM object is still valid

 
 
Robert Inder
Guest
Posts: n/a
 
      07-28-2006

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.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
event queue / checking if pointers are still valid copx C Programming 7 03-24-2006 05:58 PM
Convert a XML DOM Object to a HTML DOM Object manjunath.d@gmail.com XML 0 09-20-2005 08:16 AM
Socket and checking for valid host/port Berlin Brown Java 3 07-01-2005 09:26 AM
wxTreeCtrl checking for valid IDs Martin Drautzburg Python 0 12-27-2004 11:37 PM
checking valid filename Alex Java 8 02-08-2004 02:01 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57