IFrame src Property
Example
Change the URL of the document to embed in the iframe:
document.getElementById("myFrame").src = "http://www.cnn.com";
Try it yourself »
Definition and Usage
The src property sets or returns the value of the src attribute in an iframe element.
The src attribute specifies the URL of the document to show in an iframe.
Browser Support
The src property is supported in all major browsers.
Syntax
Return the src property:
iframeObject.src
Set the src property:
iframeObject.src=URL
Property Values
Value | Description |
---|---|
URL |
Specifies the URL of the document to embed in the iframe. Possible values:
|
Technical Details
Return Value: | A String, representing the URL of the document that is embedded in the iframe. Returns the entire URL, including the protocol (like http://) |
---|
More Examples
Example
Get the URL of the document that is shown in an iframe:
var x = document.getElementById("myFrame").src;
The result of x will be:
http://www.w3schools.com/default.asp
Try it yourself »
Related Pages
HTML reference: HTML <iframe> src attribute
IFrame Object