La propriété GlobalEventHandlers.onresize
contient un EventHandler
(gestionnaire d'évènements) qui survient quand un évènement resize
est reçu.
Syntaxe
window.onresize = funcRef;
Paramètres
funcRef
est une référence à une fonction.
Exemple
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>
Notes
L’événement resize
est déclenché après le redimensionnement de la fenêtre.
Spécification
Spécification | Statut | Commentaire |
---|---|---|
HTML Living Standard La définition de 'onresize' dans cette spécification. |
Standard évolutif |