The IFrame width property
Frame/IFrame objectDefinitions and usages
The width property can set or return the value of the width property in the iframe element.
The width property specifies the width of the iframe.
Grammar
The width property can be the following value:
value | describe |
---|---|
pixels | As in pixels (such as "100PX" or "100") |
% | As a percentage as a width (such as "20%") |
Browser support
The width property is supported by all major browsers
Change the height and width of iframe:
<html>
<head>
<meta charset="utf-8">
<title>W3Cschool在线教程(w3cschool.cn)</title>
<script>
function changeSize(){
document.getElementById("myframe").height="300";
document.getElementById("myframe").width="300";
}
</script>
</head>
<body>
<iframe id="myframe" src="http://www.w3cschool.com" rel="external nofollow" height="200" width="200">
<p>你的浏览器不支持iframes。</p>
</iframe>
<br><br>
<input type="button" onclick="changeSize()" value="修改大小">
</body>
</html>
Try it out . . .
Frame/IFrame object