ウインドウの高さ・幅を取得する
サンプルソース
<script language="Javascript"> <!-- //通常の場合 alert(document.documentElement.clientHeight); alert(document.documentElement.clientWidth); //IE(互換モード)の場合 alert(document.body.clientHeight); alert(document.body.clientWidth); --> </script> |
解説
document.documentElement.clientHeightでウィンドウの高さを、document.documentElement.clientWidthでウィンドウの幅を取得します。IE(互換モード)の場合、値が取得できないため、document.body.clientHeightとdocument.body.clientWidthを使用します。
関連する内容
- ウインドウを開く
- ウインドウを開く(モーダル)
- ウインドウを開く(モーダレス)
- ウインドウを閉じる
- ウインドウの大きさを変更する
- ウインドウの位置を変更する
- ウインドウを徐々に大きくする
- ウインドウのスクロール量を取得する