I am trying to force my website to scroll to the top when a page is reloaded and it is working everywhere except iOS which doesn't support beforeunload, I was wondering if there are any other events that are triggered when a page is refreshed.
Solution for All other browsers
$(window).on('beforeunload', function(){
$(window).scrollTop(0);
});
What I have tried for iOS but no luck
$(window).on('pageshow', function(){
$(window).scrollTop(0);
});
$(window).on('pageshow', function(){
$(window).scrollTop(0);
});
$(window).on('popstate', function(){
$(window).scrollTop(0);
});
Threads I Have Checked
Alternative for jQuery beforeunload event handler on mobile devices
Is the onbeforeunload event not supported on iPhone?
Is there an alternative method to use onbeforeunload in mobile safari?