Search w3schools.com:

SHARE THIS PAGE

Frame/IFrame src Property

Frame/IFrame Object Reference Frame/IFrame Object

Definition and Usage

The src property sets or returns the value of the src attribute in a frame/iframe element.

The src attribute specifies the URL of the document to show in a frame/iframe.

Syntax

frameObject.src=URL

or

iframeObject.src=URL


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The src property is supported in all major browsers.


Example

Example

Change the src attribute of an iframe:

<html>
<head>
<script>
function changeSrc()
{
document.getElementById("myframe").src="http://google.com";
}
</script>
</head>
<body>

<iframe id="myframe" src="/default.asp">
<p>Your browser does not support iframes.</p>
</iframe>
<br><br>

<input type="button" onclick="changeSrc()" value="Change Source">

</body>
</html>

Try it yourself »


Frame/IFrame Object Reference Frame/IFrame Object

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]