<p>Because of several iframes, XUL browser elements, and so forth, I have a number of window objects in my XULRunner application. I'm looking for the best way to find the window object that a specified node belongs to using JavaScript.</p>

<p>So, to be more specific, given node x, I need to find the specific window object that contains x.</p>

You may want to use
self
.  self is a reference to the current document.
From within the iframe:
```
```
<body>
<div id="example">Example!</div>
<script type="text/javascript">
    window.onload = function () {
        var exampleNode = document.getElementById('example');
        exampleNode.bar = function () {
            // The highest window object:
            top;
            // The parent node:
            self;
            // The parent node ( except in IE );
            this.ownerDocument.defaultView;
        };
    };
</script>
</body>
```
```
Traversing Multiple Window Objects:
Within the browser object model, the primary window object is referred to as
top
.  Other global objects are arranged in a tree structure which stems from top.  With a reference to
top
, you can navigate to the other global objects in the tree by using their
names and relationships
, much in the same way as you
traverse the DOM
.
When you have multiple window objects, as you do in the case of an iframe (of with old school framesets), the frame has a
name attribute
.  Given the objects position relative to the top window object, you can use the name of the child to access the object.
```
<iframe src ="/default.html" name="advertisement"></iframe>
```
and then from the context of the top window:
```
self.advertisement
```