Image heightプロパティ
Image オブジェクト
定義と用法
height プロパティは、画像の height 属性値を設定または取得します。
height プロパティは画像の高さを指定します。
構文
imageObject.height=pixels
ブラウザサポート
![]()
![]()
![]()
![]()
![]()
すべての主要ブラウザが height プロパティをサポートしています。
例
例
次の例では、画像の高さと幅を設定できます。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>サンプル(example.com)</title>
<script>
function changeSize(){
document.getElementById("compman").height="250";
document.getElementById("compman").width="300";
}
</script>
</head>
<body>
<img id="compman" src="compman.gif.html" width="107" height="98">
<br><br>
<input type="button" onclick="changeSize()" value="修改图像大小">
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>サンプル(example.com)</title>
<script>
function changeSize(){
document.getElementById("compman").height="250";
document.getElementById("compman").width="300";
}
</script>
</head>
<body>
<img id="compman" src="compman.gif.html" width="107" height="98">
<br><br>
<input type="button" onclick="changeSize()" value="修改图像大小">
</body>
</html>
試してみる »
Image オブジェクト その他の拡張