IFrame src Property

❮ IFrame Object

Example

Change the URL of the document to embed in the iframe:

document.getElementById("myFrame").src = "https://wwf.org";
Try it Yourself »

Description

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:
  • 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;
Try it Yourself »

Related Pages

HTML reference: HTML <iframe> src attribute


❮ IFrame Object
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.