0
Q:

resize js

window.addEventListener('resize', function(event){
  // do stuff here
});
0
//Execute a JavaScript when the browser window is resized:

<body onresize="myFunction()">
 
0
const heightOutput = document.querySelector('#height');
const widthOutput = document.querySelector('#width');

function reportWindowSize() {
  heightOutput.textContent = window.innerHeight;
  widthOutput.textContent = window.innerWidth;
}

window.onresize = reportWindowSize;
0
<p>Resize the browser window to fire the <code>resize</code> event.</p>
<p>Window height: <span id="height"></span></p>
<p>Window width: <span id="width"></span></p>
0

New to Communities?

Join the community