IFrame src attribute
Definition and usage
src
Sets or returns the src attribute of the iframe element src attribute value.
src attribute Specifies the URL of the document to be displayed in the iframe.
Example
Example 1
Change the URL of the document to be embedded in the iframe:
document.getElementById("myFrame").src = "https://wwf.org";
Example 2
Get the URL of the document displayed in the iframe:
var x = document.getElementById("myFrame").src;
Syntax
Return the src attribute:
iframeObject.src
Set the src attribute:
iframeObject.src = URL
Attribute value
Value | Description |
---|---|
URL |
Specifies the URL of the document to be embedded in the iframe. Possible values:
|
Technical Details
Return Value: | A string value representing the URL of the document embedded in the iframe. Returns the entire URL, including the protocol (such as http://). |
---|
Browser Support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support |
Related Pages
HTML Reference Manual:HTML <iframe> src Attribute