Given an object obj, I would like to check if this object is a native HTML element. I could do:
if ( obj instanceof HTMLElement )
but this does not work through frames (for example, on objects from <iframe>), since each frame has its own constructor HTMLElement. Alternatively, I could just do:
if ( obj.tagName )
but it is not safe / reliable, since this property can be (un) intentionally added to the object.
So, is there a reliable way to do this?
source
share