The HTML DOM IFrame src Property is used to set or returns the value of the src attribute of the <iframe> element. This attribute is used to specify the URL of the document that is embedded to the iframe element.
Syntax:
- It returns the src Property.
iframeObject.src
- It is used to set the src Property.
iframeObject.src = URL
Property Values:
It contains single value URL which specifies the URL of the document that is embedded to the iframe. There are two types of URL link which are listed below:
- Absolute URL: It points to another webpage.
- Relative URL: It points to other files of the same web page.
Return value: It returns a string value which represents the URL of the document that are embedded in the Iframe Element.
Example 1: This Example illustrates how to reurn the Iframe src Property.
<!DOCTYPE html> <html> <head> <title> HTML DOM iframe src Property </title> </head> <body style="text-align:center;"> <h1>GeeksforGeeks</h1> <h2> HTML DOM iframe src Property </h2> <iframe src= id="GFG" height="200" width="400"> </iframe> <br> <br> <button onclick="Geeks()">Submit</button> <p id="sudo"></p> <script> function Geeks() { var x = document.getElementById("GFG").src; document.getElementById("sudo").innerHTML = x; } </script> </body> </html> |
Output:
Before Clicking On Button:

After Clicking On Button:

Example 2: This Example illustrates that how to set the Iframe src Property.
<!DOCTYPE html> <html> <head> <title> HTML DOM iframe src Property </title> </head> <body style="text-align:center;"> <h1>GeeksforGeeks</h1> <h2> HTML DOM iframe src Property </h2> <iframe src= id="GFG" height="200" width="400"> </iframe> <br> <br> <button onclick="Geeks()">Submit</button> <p id="sudo"></p> <script> function Geeks() { var x = document.getElementById("GFG").src = } </script> </body> </html> |
Output:
Before Clicking on Button:

After Clicking On Button:

Supported Browsers: The browsers supported by HTML DOM IFrame src Property are listed below:
- Google Chrome
- Internet Explorer
- Firefox
- Apple Safari
- Opera
Recommended Posts:
- HTML | DOM IFrame name Property
- HTML | DOM IFrame contentWindow Property
- HTML | DOM IFrame sandbox Property
- HTML | DOM IFrame height Property
- HTML | DOM IFrame srcdoc Property
- HTML | DOM IFrame contentDocument Property
- HTML | DOM IFrame width Property
- How to apply CSS property to an iframe ?
- HTML | <iframe> src Attribute
- HTML | <iframe> name Attribute
- HTML | DOM IFrame Object
- HTML | <iframe> marginwidth Attribute
- HTML | <iframe> width Attribute
- HTML | <iframe> height Attribute
- HTML | <iframe> marginheight Attribute
- HTML | <iframe> scrolling Attribute
- HTML | <Iframe> frameborder Attribute
- How to get HTML content of an iFrame using JavaScript ?
- HTML | <iframe> longdesc Attribute
- HTML | <iframe> srcdoc Attribute
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.
Improved By : shubham_singh


