window.onresize
GlobalEventHandlers.onresize
プロパティは、resize (en-US)
イベントを受信するとトリガーされる EventHandler
を含みます。
構文
window.onresize = funcRef;
引数
funcRef
: 関数への参照
例
window.onresize = doFunc;
<html> <head> <title>onresize test</title> </head> <body> <p>Resize the browser window to fire the resize event.</p> <p>Window height: <span id="height"></span></p> <p>Window width: <span id="width"></span></p> <script type="text/javascript"> var heightOutput = document.querySelector('#height'); var widthOutput = document.querySelector('#width'); function resize() { heightOutput.textContent = window.innerHeight; widthOutput.textContent = window.innerWidth; } window.onresize = resize; </script> </body> </html>
注記
ブラウザウィンドウのサイズが変更された後に resize
イベントが発生します。
仕様
使用 | ステータス | コメント |
---|---|---|
HTML Living Standard onresize の定義 |
現行の標準 |