Window frames Property

Window 对象参考手册Window Object

Example

Change the src attribute value of the first <iframe> element (index 0):

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

Try it Yourself »

Definition and Usage

The frames property returns all named frames in the window.

This collection is an array of Window objects, each Window object contains a frame or <iframe> in the window. The property frames.length stores the number of elements contained in the array frames[]. Note that the frames referenced in the frames[] array may also include frames, and they themselves also have frames[] arrays.

Tip:Useframes.lengthto get the number of frames.

Note:This property can also be used for <frame> elements, but HTML5 does not support <frame> elements.

This property is read-only.

Browser Support

Property
frames Yes Yes Yes Yes Yes

Syntax

window.frames

Technical Details

Return Value: Returns a reference to the Window object, representing all frames of the current window.

More Examples

Example

Find the number of all frames in the page, then change the src attribute of the iframe element to "https://www.example.com":

var frames = window.frames; var i; for (i = 0; i < frames.length; i++) { frames[i].location = "https://www.example.com"; }

Try it Yourself »

Window 对象参考手册Window Object Other Extensions