The onresize property of the GlobalEventHandlers interface is an EventHandler that processes resize events.

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

Syntax

window.onresize = funcRef;

Parameters

  • funcRef is a reference to a function.

Example

<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>

Specification

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

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
Basic supportChrome Full support 45Edge Full support YesFirefox Full support YesIE Full support YesOpera Full support 32Safari Full support YesWebView Android Full support 45Chrome Android Full support 45Edge Mobile Full support YesFirefox Android Full support YesOpera Android Full support 32Safari iOS Full support YesSamsung Internet Android Full support Yes

Legend

Full support  
Full support

Document Tags and Contributors

Last updated by: mfluehr,