Is there a JavaScript event I can listen to if the window and screen dimensions change? I know of the obvious resize
event, but interestingly my window and screen dimensions are changing without this event being fired.
My setup is very peculiar-- I have two external monitors, one at a normal zoom level and the other at a 200% zoom level. It seems as though in the process of loading the webpage, the window/screen dimensions (e.g. window.innerWidth
, window.innerHeight
, screen.width
, etc etc...) are changing.
As a note, the browser I am using is IE11.
You can try to listen to dimension changes in a loop with setInterval
Something like this:
"use strict";
let width = screen.width;
let height = screen.height;
function checkDimension(callback) {
if (width !== screen.width || height !== screen.height) {
console.log('Dimension was changed!');
}
}
setInterval(checkDimension, 1000);