Example 1 — Basic Read
Beginner example for window.length.
console.log(typeof window.length);
console.log(window.length); How It Works
- Step. length is a number.
- Step. Most simple pages have zero frames.

window.length is the number of child frames (such as iframes). A page with no frames has 0.
Read window.length with no parentheses.
window.length; | Call | What it does |
|---|---|
window.length | How many child frames this window contains. |
Window property in browsers. No import required.
| Parameter | Description |
|---|---|
| window.length | Read-only or assignable depending on the property. No function arguments. |
| Return Value | Description |
|---|---|
| * | How many child frames this window contains. |
Beginner example for window.length.
console.log(typeof window.length);
console.log(window.length); Beginner example for window.length.
console.log(window.length === window.frames.length); Beginner example for window.length.
if (window.length === 0) {
console.log("No child frames");
} else {
console.log("Has frames: " + window.length);
} window.length is a standard Window property in browsers.
Available in all modern browsers. Not used in plain Node.js without a DOM.
Bottom line: Safe in browsers. Skip in server-only Node scripts.
Continue through the Window properties list.
CODETOFUN NEWS
Get the latest IT news, programming updates, and technology trends directly on your phone.
Your daily dose of tech, straight to your feed.
9 people found this page helpful