How can I get the window in which an object was defined?
<p>I would like to check if an object is an instanceof a certain built-in class. The problem is that my checking code might not be in the window where the object is defined, so <code>x instanceof String</code> would return <code>false</code> even though <code>x</code> is a <code>String</code>. What I need is something like <code>x instanceof getWindowOf(x)['String']</code>? But is it possible to define a function such as <code>getWindowOf</code>?</p>

<p>Or, we could solve this in another way if we were able to get all the windows of a JS application. <code>top</code>, and looping recursively through <code>top.frames</code> come close, but we would be missing pop-ups.</p>

<p>So what's a solution?</p>

<p>Note that I am just using <code>String</code> as an example. I really want to check classes like <code>Element</code> or any other classes defined in the browser.</p>
