If you cannot use the weak links suggested by Blagoh , you can use the function Components.utils.isDeadWrapper()to check (added in Firefox 17 but still not documented):
if (Components.utils.isDeadWrapper(element))
alert("I won't touch that, it a dead object");
Unprivileged code has no way of recognizing dead objects without throwing an exception. Again, if an object throws an exception, no matter what you do, it is probably dead:
try
{
String(element);
}
catch (e)
{
alert("Better not touch that, it likely a dead object");
}
source
share