Open In App

HTML DOM IFrame name Property

Improve
Improve
Like Article
Like
Save
Share
Report

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 for the element in JavaScript.

Syntax: 

  • It returns 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 that specifies the name of the Iframe element. 

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

HTML




<!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>
    <iframe src=
            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() {
            let doc_id = document.getElementById("GFG").name;
            document.getElementById("sudo").innerHTML = doc_id;
        }
    </script>
</body>
 
</html>


Output:

Animation

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

HTML




<!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>
    <iframe src=
            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() {
            let 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>


Output:

Animation.gif

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

  • Google Chrome 1.0 and above
  • Edge 12.0 and above
  • Firefox 
  • Internet Explorer
  • Opera 
  • Safari 


Last Updated : 20 Jul, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads