THE WORLD'S LARGEST WEB DEVELOPER SITE

Window length Property

❮ Window Object

Example

Find out how many <iframe> elements there are in the window:

var x = window.length;
Try it Yourself »

More "Try it Yourself" examples below.


Definition and Usage

The length property returns the number of <iframe> elements in the current window.

Tip: This property is often used together with the window.frames property.

Note: This property will also work for <frame> elements. However, the <frame> element is not supported in HTML5.

This property is read-only.


Browser Support

Property
length Yes Yes Yes Yes Yes


Syntax

window.length

Technical Details

Return Value: A Number, representing the number of frames in the current window

More Examples

Example

Loop through all frames on a page, and change the location of all frames to "w3schools.com":

var frames = window.frames;
var i;

for (i = 0; i < frames.length; i++) {
    frames[i].location = "https://www.w3schools.com";
}
Try it Yourself »

Related Pages

HTML reference: HTML <iframe> tag


❮ Window Object