window.frames

window.frames is a collection of all of the frames in the current page. It doesn't distinguish between frames and iframes.

It doesn't matter whether there are frames on the page or not, window.frames always exists and points to window.
window.frames === window //true

So to check if there are any frames on the page, use the length property.
frames.length //1

Each frame contains another page which has its own global window object. Imagine you have a page with one iframe.
snippet
<iframe name="myframe" src="about:blank" />

To get access to the iframe's window, you can do any of these.

window.frames[0]
window.frames[0].window
frames[0].window
frames[0]

Access child properties from parent
We can access properties of the child frame from the parent page

For example, you can reload the frame like this.
frames[0].window.location.reload()

Accessing child from parent
From inside the child you can access the parent:

frames[0].parent === window // true
Using a property called top, you can access the topmost page (the one that contains all the other frames) from within any frame:
window.frames[0].window.top === window //true
window.frames[0].window.top === window.top //true
window.frames[0].window.top === top //true

In addition, self is the same as window.
self === window //true
frames[0].self == frames[0].window //true

If a frame has a name attribute, you can also access the frame by name, not only by index.
window.frames['myframe'] === window.frames[0] //true
Related Tutorial
2 window
Follow Us
https://www.facebook.com/Rookie-Nerd-638990322793530 https://twitter.com/RookieNerdTutor https://plus.google.com/b/117136517396468545840 #