Answers for "window.onchange size"

17

js window resize listener

//listen for window resize event
window.addEventListener('resize', function(event){
    var newWidth = window.innerWidth;
    var newHeight = window.innerHeight; 
});
Posted by: Guest on July-31-2019
0

window.onchange size

// Get current width and height (does not change the variables automatically)
let width = window.innerWidth;
let height = window.innerHeight;

// Updates the variables every time the window resizes
window.addEventListener("resize", function(event) {
  width = window.innerWidth;
  height = window.innerHeight;
});
Posted by: Guest on October-26-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language