Grow your CSS skills. Land your dream job.

Reload page when browser hits a specific width

  • # March 6, 2013 at 2:21 pm

    Hey, does anyone know how to reload a page when the browser hits 768px? Right now I am using a code that reloads the page when the width is changed to anything but I only need it to reload when it hits specific widths.

    Thanks!

    # March 6, 2013 at 3:14 pm

    I’m not sure why you would want to do this, and it seems like bad practice, but here’s how you could do this with jQuery:

    $(window).on(“resize”, function() {
    var w = $(this).width();
    if ( w === 768 ) {
    location.reload();
    }
    });

    # March 6, 2013 at 3:24 pm

    JoshBlackwood, thanks for the help…I figured it would be bad practice so ill look into my code and try to find out whats causing the problem.

    # March 6, 2013 at 5:05 pm

    @mdyorke,

    Hey, what is the problem and conditions for it? For what purpose does it need to ‘reload’? There could be a totally different solution.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".