One way would be to initialize a variable to false on page load, and then on your popstate event, check that variable. If it's still false, set it to true and do nothing. From then on all of your other popstate events should be only from back/forward events.
var loaded = false;
window.onpopstate = function(e) {
if (!loaded) {
loaded = true;
return;
} else {
// run your stuff...
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…