How do I check if a variable is of type DOMWindow in Google Chrome? When I try referencing the DOMWindow type, I get a ReferenceError. For example, when I try checking the type of window in the console:
> window instanceof DOMWindow
ReferenceError: DOMWindow is not defined
But window is clearly of type DOMWindow. What am I doing wrong?
What am I doing wrong?
You get a reference error ReferenceError: DOMWindow is not defined
because there is no DOMWindow
member on the global object to check against.
You get the same error if you type window instanceof rubbish
window.constructor.name
may give you what you want (a string "DOMWindow" to check against), althogh I should warn you that it's non-standard.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With