Moon icon indicating copy to clipboard operation
Moon copied to clipboard

Back button cache issue in Safari

Open mychele opened this issue 9 years ago • 2 comments

Hi, first of all thanks for the nice template. I experienced an issue with Safari on OSX 10.11.6, which is related to the annoying Safari back button cache problem. For example, when using the browser back button to go back to the previous page, the content is not displayed anymore, i.e., only the background and the menu on top are shown, but the central content is not. By following these indications, I managed to solve it. I added window.onpageshow = function(event) { if (event.persisted) { window.location.reload() } }; to scripts.js in assets/js/ and everything seems to work! The only annoying thing is that Safari has to reload the page. Is there any more elegant solution? Thanks, Michele

mychele avatar Jul 30 '16 09:07 mychele

Sorry, I'm not good at JS. I will keep this issue open, so maybe someone can solve it.

TaylanTatli avatar Dec 22 '16 16:12 TaylanTatli

Add this to assets/js/scripts.js:

// Safari back-button fix
window.onpageshow = function(event) {
    if ($(".container").hasClass('fadeOut')) {
        $(".container").removeClass("fadeOut").addClass("fadeIn");
    }
    if ($(".wrapper").hasClass('fadeOut')) {
        $(".wrapper").removeClass("fadeOut").addClass("fadeIn");
    }
}

jeremyvaartjes avatar Jan 25 '17 04:01 jeremyvaartjes