According to spec, only the BODY and FRAMESET elements provide an \"onload\" event to attach to, but I would like to know when a dynamically-create
BODY
FRAMESET
Instead of walking the DOM tree up to the document element just use element.ownerDocument. see here: https://developer.mozilla.org/en-US/docs/DOM/Node.ownerDocument and do this:
element.ownerDocument
element.ownerDocument.body.contains(element)
and you're good.