How can I refresh the screen on browser resize?
Update for anyone viewing this now. JQuery now considers bind a deprecated function.
And the way proximus' response works (at least in Opera/Chrome/Firefox) it constantly polls for resizing even if the browser is just sitting there. It appears that the resize function was called automatically when it hit location.reload(), causing it to hit an infinite loop. Here's what I pulled together that also solved the problem.
jQuery(function($){
var windowWidth = $(window).width();
var windowHeight = $(window).height();
$(window).resize(function() {
if(windowWidth != $(window).width() || windowHeight != $(window).height()) {
location.reload();
return;
}
});
});
Here's a pure JS solution, because I think it's not fair to use jQuery for everything.
window.addEventListener('resize', function () {
"use strict";
window.location.reload();
});
A drawback is that it won't work in IE "browser" older than 9.
If you're looking for a jQuery solution, you can use something like this:
$(window).bind('resize', function() {
location.reload();
});
Maybe it makes sense to additionally use a timeout...