Latest web development tutorials

HTML DOM IFrame height property

Frame / IFrame Object Reference Frame / IFrame objects

Definition and Usage

height property sets or returns the value of the iframe element height attribute.

iframe height attribute specifies the height (in pixels or as a percentage).

grammar

iframeObject.height=value

height attribute can have the following values:

描述
pixels height 属性单位可以是像素 (如 "100px" 或者 "100")
% height 属性单位可以是百分比 (如"20%")


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support height attribute


Examples

Examples

Change iframe height and width:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
<script>
function changeSize(){
    document.getElementById("myframe").height="300";
    document.getElementById("myframe").width="300";
}
</script>
</head>
<body>
    
<iframe id="myframe" src="http://www.w3big.com" height="200" width="200">
<p>你的浏览器不支持iframes。</p>
</iframe>
<br><br>
<input type="button" onclick="changeSize()" value="修改大小">

</body>
</html>

try it"


Frame / IFrame Object Reference Frame / IFrame objects