Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Onze vrijwilligers hebben dit artikel nog niet naar het Nederlands vertaald. Doe mee en help de klus te klaren!

The GlobalEventHandlers.onresize property contains an EventHandler triggered when a resize event is received.

Syntax

window.onresize = funcRef;

Parameters

  • funcRef is a reference to a function.

Example

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

The resize event is fired after the window has been resized.

Specification

Specification Status Comment
WHATWG HTML Living Standard
The definition of 'onresize' in that specification.
Living Standard  

Documentlabels en -medewerkers

Labels: 
 Aan deze pagina hebben bijgedragen: Garbee, cvrebert, mrec, teoli, fscholz, kosvrouvas, libreGeekingKid, Sheppy, ziyunfei, Rikdc, Jabez, Rappo
 Laatst bijgewerkt door: Garbee,