Skip to content
Related Articles

Related Articles

HTML | DOM Window frames Properties

View Discussion
Improve Article
Save Article
  • Last Updated : 01 Jun, 2022
View Discussion
Improve Article
Save Article

The Window frames property in HTML DOM is used to return the frame element in the form of an array object. This property represents all <iframe> elements in the current window. DOM Windowframe is a read-only property. 

Syntax:

window.frames

Return Value: It returns a reference to the Window object, representing all the frames in the current window. 

Properties:

  • length property: It returns the number of iframe elements in the current window. 

Syntax:

window.length

Example 1: 

HTML




<!DOCTYPE html>
<html>
     
<head>
    <title>
        HTML | DOM Window frames Property
    </title>
</head>
 
<body>
     
    </iframe><br>
     
    <p>
        Click on the button to display
        the number of iframes
    </p>
     
    <button onclick="myGeeks()">
        Click Here!
    </button>
     
    <p id = "GFG"></p>
     
    <!-- script to count iframes -->
    <script>
        function myGeeks() {
            var x = window.length;
            document.getElementById("GFG").innerHTML = x;
        }
    </script>
</body>
 
</html>                   

Output: Before click on the button:

  

After click on the button:

 

  • location property: It changes the location of iframe. 

Syntax:

window.frames[index_no].location

Example 2: 

HTML




<!DOCTYPE html>
<html>
     
<head>
    <title>
        HTML DOM Window frames Property
    </title>
</head>
 
<body>
     
    </iframe><br>
     
    <p>
        Click on the button to display
        the number of iframes
    </p>
     
    <button onclick = "myGeeks()">
        Click Here!
    </button>
     
    <p id = "GFG"></p>
     
    <!-- script to count iframes -->
    <script>
        function myGeeks() {
            window.frames[0].location =
        }
    </script>
</body>
 
</html>                   

Output: Before click on the button:

  

After click on the button:

 

Supported Browsers: The browser supported by DOM Window Frames Property are listed below:

  • Google Chrome 1 and above
  • Edge 12 and above
  • Internet Explorer 4 and above
  • Firefox 1 and above
  • Opera 12.1 and above
  • Safari 1 and above

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!