The title pretty much says it all. I need to check whether an object is an instance of the DOM:Window interface. window
will pass the test, window.frames[xyz]
as well, should the iframe exist.
The most intuitive way appears to be a simple instanceof check via object instanceof window.constructor
. It's a sad state of affairs that there are browsers (like IE6), whose window.constructor
equals to undefined
.
What would you suggest? There are always hacky, ugly and toString
dependant ways like /\[object.*window.*\]/i.test(object)
, but I would rather go for a simple, clean solution, if possible.