How to refer to the DOMWindow type in Google Chrome?

How to check if a variable is of type DOMWindow in Google Chrome? When I try to reference the DOMWindow type, I get a ReferenceError. For example, when I try to check the type of window in the console:

> window instanceof DOMWindow

   ReferenceError: DOMWindow is not defined

But the window is clearly of type DOMWindow. What am I doing wrong?

+5
source share
2 answers

What am I doing wrong?

You get a reference error ReferenceError: DOMWindow is not definedbecause there is no item DOMWindowto check on the global object .

You will get the same error if you type window instanceof rubbish

window.constructor.name , ( "DOMWindow" ), althogh , .

+4

.constructor. :

alert(window.constructor);

DOMWindow , , Chrome.

+2

All Articles