Frame/IFrame src property

HTML DOM Frame/IFrame src property Frame/IFrame object

Definitions and usages

The src property can set or return the value of the src property in the frame/iframe element.

The src property specifies the URL of the document that is loaded into the frame/iframe.

Grammar

frameObject.src= URL

or

iframeObject.src= URL


Browser support

HTML DOM Frame/IFrame src property HTML DOM Frame/IFrame src property HTML DOM Frame/IFrame src property HTML DOM Frame/IFrame src property HTML DOM Frame/IFrame src property

The src property is supported by all major browsers


Change the src property in iframe:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>W3Cschool在线教程(w3cschool.cn)</title>
<script>
function changeSrc(){
document.getElementById("myframe").src="http://www.baidu.com" rel="external nofollow" ;
}
</script>
</head>
<body>

<iframe id="myframe" src="http://www.w3cschool.com" rel="external nofollow" >
<p>你的浏览器不支持iframes。</p>
</iframe>
<br><br>
<input type="button" onclick="changeSrc()" value="修改源链接">

</body>
</html>

Try it out . . .


HTML DOM Frame/IFrame src property Frame/IFrame object