The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Triggering Page Refresh when media query changes

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #239884

    My site has multiple media queries … Currently I have the following javascript telling the page to reload every time the browser is resized … I’d only like the page to refresh when the media query changes …
    <script type=”text/javascript”>
    $(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);

    —- I don’t like this because every time you change the browser size at all … it refreshes the page and it’s just bothersome … can’t I accomplish what I want wit hJavascript? if the media query changes … tell the page to refresh?


    I feel like this is a less than ideal solution to a problem that could be solved differently… why do you need the page to refresh at all? The page layout should be changing as you hit your break points without need of a refresh… are you maybe positioning things with JS on document ready or something like that?

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.