HTML DOM Frame / IFrame src attribute
Definition and Usage
src property sets or returns the value frame / iframe element src attribute.
src attribute specifies the loaded frame / iframe in the document URL.
grammar
frameObject.src=URL
或者
iframeObject.src=URL
或者
iframeObject.src=URL
Browser Support
All major browsers support the src attribute
Examples
Examples
Change the iframe src attribute:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
<script>
function changeSrc(){
document.getElementById("myframe").src="http://www.baidu.com";
}
</script>
</head>
<body>
<iframe id="myframe" src="http://www.w3big.com">
<p>你的浏览器不支持iframes。</p>
</iframe>
<br><br>
<input type="button" onclick="changeSrc()" value="修改源链接">
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
<script>
function changeSrc(){
document.getElementById("myframe").src="http://www.baidu.com";
}
</script>
</head>
<body>
<iframe id="myframe" src="http://www.w3big.com">
<p>你的浏览器不支持iframes。</p>
</iframe>
<br><br>
<input type="button" onclick="changeSrc()" value="修改源链接">
</body>
</html>
try it"
Frame / IFrame objects