Window frames
Example
Change the location of the first frame:
window.frames[0].location = "https://www.w3schools.com/jsref/";
Try it Yourself »
More examples below.
Definition and Usage
The frames
property returns an array with all window objects in the window.
The frames
property is read-only.
The windows can be accessed by index numbers. The first index is 0.
Note
A frame can be any embedding element:
<frame>, <iframe>, <embed>, <object>, etc.
See Also:
Syntax
window.frames
Return Value
Type | Description |
An array | All window objects in the window. |
More Examples
Example
Loop through all frames and change the color:
const frames = window.frames;
for (let i = 0; i < frames.length; i++) {
frames[i].document.body.style.background = "red";
}
Try it Yourself »
Browser Support
window.frames
is supported in all browsers:
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | Yes |