var width = window.innerWidth; window.onresize = function (){ if(window.innerWidth != width){ location.reload() } console.log(window.innerWidth) }