Back button cache issue in Safari
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
Sorry, I'm not good at JS. I will keep this issue open, so maybe someone can solve it.
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");
}
}