I'm running into a situation where pressing the back arrow on an iPhone in Chrome/Safari will render the previous page's loading overlay. I have tried a number of code snippets found whilst googling but the only one that worked caused Chrome on Android to have to press the back arrow twice. Anyone have an suggestions for a more reliable solution?
This is NOT a single page app, the problem is simply hiding the previous page's loading overlay so when the back arrow is pressed the user doesn't see the overlay until they click another link.
Side note, Android correctly handles the back arrow without any extra code.
// Works on iPhone but on Android have to press back arrow twice
window.onpopstate = function() {
jQuery("#ajax-activity-wrap").hide();
}; history.pushState({}, '');
// Weird behavior encountered on iPhone where reload goes back to previous page (obvious)
window.onpopstate = function() {
history.back();
jQuery("#ajax-activity-wrap").hide();
}; history.pushState({}, '');