Window frames property

Definition and usage

frames Property returns an array containing all window objects in the window.

frames Properties are read-only.

These windows can be accessed by index. The first index is 0.

Tip:Frames can be any embedded element:<frame>, <iframe>, <embed>, <object> etc.

See also:

length attribute

frameElement attribute

Instance

Example 1

Change the location of the first frame:

window.frames[0].location = "https://www.codew3c.com/jsref/";

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.frames

Return value

Type Description
Array All window objects in the window.

Browser support

All browsers support window.frames:

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