window resize event javascript code example

Example 1: window resize event javascript

//listen for window resize event
window.addEventListener('resize', function(event){
    var newWidth = window.innerWidth;
    var newHeight = window.innerHeight; 
});

Example 2: javascript resize event

window.resize = event => {
  // Code here
};

Example 3: detect resize window javascript

window.addEventListener('resize', functionName);

Example 4: js windowresize event

Resize the browser window to fire the resize event.

Window height:

Window width:

Tags:

Misc Example