Know if a DOM object is dead

<>

This question already has an answer here:

Answers


copied from How to check if element exists in the visible DOM?

   var elementInDocument = function(element) {
        while (element = element.parentNode) {
            if (element == document) {
                return true;
            }
        }
        return false;
    }

You can use it like:

if(elementInDocument(element))
    alert("Do something");

//eval it in your mozilla-browser space

var dc = content.document;
content.document.location.reload();
setTimeout(function(){ 
  try{ 
    dc.parentNode;
  }catch(e){
    if (e.message.indexOf(' dead ')!=-1){
        alert('REALY DEAD!');
    }
} }, 1000);

it is a test of dead (in try..catch block) in my moz extension projects.


Need Your Help

adding UIView into subView of cell, UITableViewController

ios uitableview uilabel

Im adding 2 texts into a cell of a table. What I am doing is

wrong sequence of libserial received data

c++ linux serial-port libserial

I'm now working on a project which uses libserial for serial port communication under Ubuntu. we modified the libserial source code to allow MARK/SPACE parity. but when doing data receiving test,

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.