HTML DOM IFrame height 屬性
定義和用法
height 屬性可設置或者返回iframe 元素中height 屬性的值。
height 屬性指定了iframe 的高度(以像素或百分比為單位)。
語法
iframeObject.height=value
height 屬性可以是以下值:
值 | 描述 |
---|---|
pixels | height 属性单位可以是像素 (如 "100px" 或者 "100") |
% | height 属性单位可以是百分比 (如"20%") |
瀏覽器支持
所有主要瀏覽器都支持height 屬性
實例
實例
改變iframe 的高度與寬度:
<!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>
<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>
嘗試一下»
Frame/IFrame對象