JavaScript入門講座

Home > imageオブジェクト > vspaceプロパティ

vspaceプロパティ

imageオブジェクトのvspaceプロパティはイメージファイルの縦間隔を返します。

書式document.images[index番号].vspace
document.イメージファイル名.vspace
対応Internet ExplorerFireFoxChromeSafariOpera
イメージファイルの縦間隔
使用例イメージファイルの縦間隔を表示する。

<html>
<head>
<title>JavaScript image vspace</title>
<script type="text/javascript">
function dispImgVspace(){
    for(var i=0 ; i < document.images.length ; i++){
        alert('イメージファイルの縦間隔:' + document.images[i].vspace);
    }
}
</script>
</head>
<body>
<img src="imgFile1.jpg" name="file1" alt="イメージファイル1"
 width="50px" height="50px" lowsrc="imglowFile1.jpg"
 border="2" hspace="10" vspace="15">
<img src="imgFile2.jpg" name="file2" alt="イメージファイル2"
 width="100px" height="100px" lowsrc="imglowFile2.jpg"
 border="3" hspace="20" vspace="25">
<img src="imgFile3.jpg" name="file3" alt="イメージファイル3"
 width="200px" height="200px" lowsrc="imglowFile3.jpg"
 border="4" hspace="30" vspace="35">
<form name="fm">
イメージファイルの縦間隔を表示する
<input type="button" value="確認" onclick="dispImgVspace()">
</form>
</body>
</html>
						
関連メンバ
heightイメージの高さ
width画像の幅
hspace画像の横間隔