Properti ketinggian HTML DOM iFrame
Frame / benda iFrame
Definisi dan Penggunaan
tinggi set properti atau mengembalikan nilai dari atribut tinggi iframe elemen.
Atribut tinggi iframe menentukan ketinggian (dalam pixel atau sebagai persentase).
tatabahasa
iframeObject.height=value
atribut tinggi dapat memiliki nilai berikut:
值 | 描述 |
---|---|
pixels | height 属性单位可以是像素 (如 "100px" 或者 "100") |
% | height 属性单位可以是百分比 (如"20%") |
Dukungan Browser
Semua browser utama mendukung atribut tinggi
contoh
contoh
Mengubah tinggi iframe dan lebar:
<!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>
Coba »
Frame / benda iFrame