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
Property | |||||
---|---|---|---|---|---|
src | Yes | Yes | Yes | Yes | Yes |
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