Window frames Property
Example
Change the location of the first <iframe> element (index 0) in the current window:
window.frames[0].location = "https://www.w3schools.com/jsref/";
Try it Yourself »
More "Try it Yourself" examples below.
Definition and Usage
The frames property returns an array-like object, which represents all <iframe> elements in the current window.
The <iframe> elements can be accessed by index numbers. The index starts at 0.
Tip: Use frames.length to find the number of frames.
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 | |||||
---|---|---|---|---|---|
frames | Yes | Yes | Yes | Yes | Yes |
Syntax
window.frames
Technical Details
Return Value: | Returns a reference to the Window object, representing all 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