I use pushState and create a pageview on popstate events based on the history.state of the current page.
If there is no story. Status (hopefully) to reload the document.
window.onpopstate = function(event) { if( window.history.state !== null ){ // page was ajax created and history created by pushState // recreate with ajax } else{ // page was loaded from server normally document.location.reload() } }
The problem is that Safari fires a popstate event when the page loads. Chrome and Firefox launch pop-ups on the back of the browser.
I want to ignore the start popstate event of loading on Safari (ideally without setTimeout and without browser detection).
In addition, the site is a mixture of links - some of which will launch pushState and some that will load normally from the server - so if the user has ten pages in the navigation history and clicking the "Back" button, there will be a mix of pushState and pages without pushState.
javascript jquery safari
tgrass
source share