ウィンドウinnerWidth
例
ウィンドウ幅を取得します。
let width = window.innerWidth;
let width = innerWidth;
以下のその他の例。
定義と使用法
innerWidth
プロパティは、ウィンドウのコンテンツ領域の幅を返します。
innerWidth
プロパティは読み取り専用です。
構文
window.innerWidth
あるいは単に:
innerWidth
戻り値
タイプ | 説明 |
数 | ブラウザウィンドウのコンテンツ領域の内側の幅(ピクセル単位)。 |
その他の例
すべての高さと幅のプロパティ:
let text =
"<p>innerWidth: " + window.innerWidth + "</p>" +
"<p>innerHeight: " + window.innerHeight + "</p>" +
"<p>outerWidth: " + window.outerWidth + "</p>" +
"<p>outerHeight: " + window.outerHeight + "</p>";
ブラウザのサポート
window.innerWidth
すべてのブラウザでサポートされています:
Chrome | IE | Edge | Firefox | Safari | Opera |
Yes | 9-11 | Yes | Yes | Yes | Yes |