I am using this bit of code successfully:
$(window).bind('resize',function() {
window.location.href = window.location.href;
});
But my problem is, I only want to reload / refresh the window when scaling between 320px and 480px. If I resize between 480px and 960px for example, I do not need the window to reload, so I need to find a way to restrict this to <= 480px I guess.
Any help would be greatly appreciated.
Thanks,
EDIT BELOW
In response to Kolink:
Okay, so I sort of got it working using this:
$(window).bind('resize',function() {
var winWidth = $(window).width();
if (winWidth < 480) {
window.location.href = window.location.href;
}
else {
// nothing
}
});
Problem is now, it is constantly reloading on the iphone. If I go from portrait to landscape on the iphone, it just keeps reloading over and over again. Any suggestions?
Just use a simple
ifstatement, checking the size of the window and only reloading if necessary.