Window frames property

Definition and usage

frames The property returns an array containing all the window objects in the window.

frames The properties are 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:

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
Soporte Soporte Soporte Soporte Soporte Soporte

Páginas relacionadas

Objeto IFrame del DOM HTML

Etiqueta <iframe> de HTML