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
Here is another solution to the problem extracted from the jQuery code. The following function can be used to check if a node is attached to the DOM or if it is "disconnected".
function isDisconnected( node ) { return !node || !node.parentNode || node.parentNode.nodeType === 11; }
A nodeType === 11 defines a DOCUMENT_FRAGMENT_NODE, which is a node not connected to the document object.
For further information see the following article by John Resig: http://ejohn.org/blog/dom-documentfragments/