Window length property
- Previous Page innerWidth
- Next Page localStorage
- Go to the Previous Level Window Object
Definition and usage
length
The property returns the number of windows (frames) in the window.
length
The property is read-only.
These windows can be accessed by index number. The first index is 0.
Tip:Frames can be any embedded element:<frame>, <iframe>, <embed>, <object> et al.
See also:
Instance
Example 1
How many windows are in the window:
let length = window.length;
Example 2
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"; }
Syntax
window.length
Return value
Type | Description |
---|---|
Number | The number of windows in the current window. |
Browser support
All browsers support window.length
:
Chrome | IE | Edge | Firefox | Safari | Opera |
---|---|---|---|---|---|
Chrome | IE | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support | Support |
- Previous Page innerWidth
- Next Page localStorage
- Go to the Previous Level Window Object