Window length
Example
How many windows are in the window:
let length = window.length;
Try it Yourself »
More examples below.
Description
The length
property returns the number of (framed) windows in the window.
The length
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.length
Return Value
Type | Description |
A number | The number of windows in the current window. |
More Examples
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.lenght
is supported in all browsers:
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | Yes |