La proprietà GlobalEventHandlers.onresize
contiene un EventHandler
il quale viene lanciato quando un evento resize
viene ricevuto.
Sintassi
window.onresize = funcRef;
Parameters
funcRef
è un riferimento ad una funzione.
Esempio
window.onresize = doFunc;
<html> <head> <title>onresize test</title> </head> <body> <p>Ridimensiona la finestra del browser per lanciare l'evento resize.</p> <p>Altezza finestra: <span id="height"></span></p> <p>Larghezza finestra: <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>
Note
L'evento resize viene scatenato dopo che la finestra è stata ridimensionata.
Specifiche
Specificazione | Stato | Commento |
---|---|---|
HTML Living Standard The definition of 'onresize' in that specification. |
Living Standard |