Refresh Page On Resize With Javascript Or Jquery
I want to force the browser to refresh the page when the user resizes it. I have following code: function refresh() { location.reload(); } but i
Solution 1:
Do it with javascript/jquery:
just javascript:
window.onresize = function(){ location.reload(); }
with jquery:
$(window).resize(function(){location.reload();});
or
$(window).on('resize',function(){location.reload();});
Solution 2:
The following code seems to work with all browsers,
$(window).bind('resize', function(e)
{
if (window.RT) clearTimeout(window.RT);
window.RT = setTimeout(function()
{
this.location.reload(false); /* false to get page from cache */
}, 100);
});
Hope it helps everyone. I found this information here: http://www.jquery4u.com/snippets/jquery-refresh-page-browser-resize/
Solution 3:
try this:
$(window).resize(function() {
location.reload();
});
Post a Comment for "Refresh Page On Resize With Javascript Or Jquery"