IFrame height 屬性

Frame/IFrame 對(duì)象參考手冊(cè) Frame/IFrame 對(duì)象

定義和用法

height 屬性可設(shè)置或者返回 iframe 元素中 height 屬性的值。

height 屬性指定了 iframe 的高度(以像素或百分比為單位)。

語法

iframeObject.height=value

height 屬性可以是以下值:

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


瀏覽器支持

Internet ExplorerFirefoxOperaGoogle ChromeSafari

所有主要瀏覽器都支持 height 屬性


實(shí)例

實(shí)例

改變 iframe 的高度與寬度:

<!DOCTYPE html>
<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="/upload/help/http://www.w3cschool.com" height="200" width="200">
<p>你的瀏覽器不支持iframes。</p>
</iframe>
<br><br>
<input type="button" onclick="changeSize()" value="修改大小">

</body>
</html>

嘗試一下 ?


Frame/IFrame 對(duì)象參考手冊(cè) Frame/IFrame 對(duì)象