ブラウザのサイズを調べる

無料・有料 レンタルサーバー比較


ブラウザ
Internet Explorer Netscape Firefox Opera
参考
JavaScriptの基本

ブラウザの表示領域(各種バーを含まない領域)を表示するスクリプトです。


ソース

<html>
<head>
<title>HTML index Webサイト</title>
</head>
<body>

<script type="text/javascript">
<!--

if(document.all){ // IE用

	document.write('<p>横のサイズ:<strong>' + document.body.clientWidth + '</strong><br>');
	document.write('縦のサイズ:<strong>' + document.body.clientHeight + '</strong></p>');

}

else{

	document.write('<p>横のサイズ:<strong>' + innerWidth + '</strong><br>');
	document.write('縦のサイズ:<strong>' + innerHeight + '</strong></p>');

}

// -->
</script>

</body>
</html>

解説

表示したい場所にスクリプトを記述します。

ブラウザの縦と横のサイズを取得して表示します。

※サイズの取得方法はIEとそれ以外では異なります。

青い文字の部分は、必要に応じて書き換えてください。



inserted by FC2 system