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.
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 > 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 > |
Output: Before Clicking on Button:
After Clicking on Button:
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 > 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 > |
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 1.0 and above
- Edge 12.0 and above
- Firefox
- Internet Explorer
- Opera
- Safari
Please Login to comment...