Window length property

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:

frames property

frameElement property

Instance

Example 1

How many windows are in the window:

let length = window.length;

Try it yourself

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";
}

Try it yourself

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

Related Pages

HTML DOM IFrame Object

HTML <iframe> Tag