HTML DOM Window frameElement property returns the iframe element in which the window is embedded or stored. If it is not stored, in that case, it simply returns a null value.
Syntax:
window.frameElement
Return Value: It returns an IFrame object or null.
Example:
html
<!DOCTYPE html>
<html>
<head>
<title>
HTML | DOM Window frameElement Properties
</title>
</head>
<body>
<p>
click on the button. IF the window is in
iframe then it will change its URL to
geekforgeeks official website.
</p>
<button onclick="myFunction()">
Click!
</button>
<script>
function myFunction() {
var iframe = window.frameElement;
// IF WINDOW IS NOT EMBEDDED
// THEN IFRAME WILL HAVE A NULL VALUE.
if (iframe) {
iframe.src =
}
}
</script>
</body>
</html>
|
Output: Before clicking:
After clicking:
Supported Browser: The browser supported by DOM Window frameElement Properties are listed below:
- Google Chrome 1.0 and above
- Edge 12 and above
- Internet Explorer 5.5 and above
- FireFox 1.0 and above
- Opera 12.1 and above
- Safari 3.0 and above
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!