Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reference DOMWindow type in Google Chrome?

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?

like image 839
Shawn O'Hern Avatar asked Jan 20 '11 02:01

Shawn O'Hern


1 Answers

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.

like image 95
25 revs, 4 users 83% Avatar answered Oct 04 '22 17:10

25 revs, 4 users 83%