Link to home
Start Free TrialLog in
Avatar of Robert Granlund
Robert GranlundFlag for United States of America

asked on

JQuery to refresh browser when Browser is resized

I found the following function that will refresh my browser when the browser is resized.  Is this the best way to do it or is there a better code that works cross browser?

/refresh page on browser resize
$(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 */
  }, 200);
});

Open in new window

Avatar of Gary
Gary
Flag of Ireland image

Whats the point of the reload?
That would be a good way of doing it, but I'm with Gary, why would you want to do this?
$(window).resize(function () { location.reload();});
Avatar of Robert Granlund

ASKER

On the pages of my site, I'm using Cufon.js Font replacement.  When I size down my screen for a responsive design the page needs to reload for the new CSS at specific break points.  There are different font sizes at different browser sizes.  Without the page refreshing the design does not "Snap" into the new css parameters.

Is there a better way to do this?

In addition to this question, If I have a form on a page, is there a way to keep the form from re-submitting if the page refreshes?
ASKER CERTIFIED SOLUTION
Avatar of Gary
Gary
Flag of Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Oh, that is great, that is exactly what I needed.