HTML | DOM IFrame name Property

The HTML DOM IFrame name property is used to set or return a value of the name attribute of the Iframe element. The name attribute is used as a reference of the element in JavaScript.

Syntax:

  • It return the name property.
    iframeObject.name
  • It is used to set the name property.
    iframeObject.name = name

Property Values:



  • name: It is used to specify the name of the Iframe Element.

Return Value: It returns a string value which specify the name of the Iframe element.

Example1: This example illustrates how to return the Iframe name property.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html> 
<html
  
<head
    <title
        HTML DOM iframe name property 
    </title
</head
  
<body style="text-align:center;"
      
    <h1>GeeksforGeeks</h1
      
    <h2>HTML DOM iframe name Property</h2
      
        id="GFG" height="200" width="400" name="myGeeks">
    </iframe
      
    <br><br>
      
    <button onclick="Geeks()">Submit</button>
      
    <p id="sudo" style="font-size:20px"></p>         
      
    <script>
        function Geeks() {
            var doc_id = document.getElementById("GFG").name;
            document.getElementById("sudo").innerHTML = doc_id;
        }
    </script>
</body
  
</html>

chevron_right


Output:
Before Clicking on Button:

After Clicking on Button:

Example 2: This example illustrates how to set the Iframe name property.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html> 
<html
  
<head
    <title
        HTML DOM iframe name property 
    </title
</head
  
<body style="text-align:center;"
      
    <h1>GeeksforGeeks</h1
      
    <h2>HTML DOM iframe name Property</h2
      
        id="GFG" height="200" width="400" name="myGeeks">
    </iframe
      
    <br><br>
      
    <button onclick="Geeks()">Submit</button>
      
    <p id="sudo" style="font-size:20px"></p>         
      
    <script>
        function Geeks() {
            var doc_id = document.getElementById("GFG").name
                        = "sudo";
            document.getElementById("sudo").innerHTML = 
                        "The value of the name attribute was"
                        + " changed to " + doc_id;
        }
    </script>
</body
  
</html>

chevron_right


Output:
Before Clicking on Button:

After Clicking on Button:

Supported Browsers: The browsers supported by HTML DOM IFrame name property are listed below:

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Safari
  • Opera


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.