Window frameElement Property
Example
Find out if the current window is in an <iframe>. If so, change its URL to "w3schools.com":
var frame = window.frameElement; // Get the <iframe> element of the window
if (frame) { // If the window is in an <iframe>, change its source
frame.src = "https://www.w3schools.com/";
}
Try it Yourself »
Definition and Usage
The frameElement property returns the <iframe> element in which the current window is inserted.
If the document window is not placed within an <iframe>, the return value of this property is null.
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
The numbers in the table specify the first browser version that fully supports the property.
Property | |||||
---|---|---|---|---|---|
frameElement | 18.0 | 6.0 | 1.0 | Yes | Yes |
Syntax
window.frameElement
Technical Details
Return Value: | An IFrame object, which is the host of the current window in the parent document, otherwise null |
---|
Related Pages
HTML DOM reference: HTML DOM IFrame Object
HTML reference: HTML <iframe> tag
❮ Window Object