HTML | DOM Window frameElement Properties

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:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!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 = 
            "https://ide.geeksforgeeks.org/";
            }
        }
    </script>
  
</body>
  
</html>

chevron_right


Output:

Before clicking:

After clicking:

Supported Browser: The browser supported by DOM Window frameElement Properties are listed below:

  • Google Chrome 18.0
  • Internet Explorer 2.0
  • FireFox 1.0
  • Opera 11.5
  • Safari 6.0


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.