X
HOME HTML5 CSS3 JAVASCRIPT SQL PHP5 JQUERY ANGULAR BOOTSTRAP3 XML MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

IFrame src Property

IFrame Object Reference IFrame Object

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

Internet Explorer Firefox Opera Google Chrome Safari

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:
  • An absolute URL - points to another web site (like src="http://www.example.com/default.htm")
  • A relative URL - points to a file within a web site (like src="default.htm")

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 Reference IFrame Object

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB HOSTING

UK Reseller Hosting

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates

SHARE THIS PAGE

facebook