Why browsers can't listen for popstate events

  1. you need to pushState and then fallback before you can enter the listening event of popstate
window.onpopstate = function(event) {
  alert("location: " + document.location + ", state: " + JSON.stringify(event.state));
};
history.pushState({page: 1}, "title 1", "?page=1");
history.pushState({page: 2}, "title 2", "?page=2");
history.replaceState({page: 3}, "title 3", "?page=3");
history.back(); // alerts "location: http://example.com/example.html?page=1, state: {"page":1}"
history.back(); // alerts "location: http://example.com/example.html, state: null
history.go(2);

if pushstate is not executed, it will not enter onpopstate if it is backed up directly. Why

Jul.06,2022

browser security policy restrictions, it is impossible for you to get the user's own history


https://developer.mozilla.org...
mdn wrote
note that calling history.pushState () or history.replaceState () will not trigger the popstate event. This event is triggered only when a browser action is made, such as when the user clicks the browser's fallback button (or calls history.back () or history.forward () method in Javascript code)

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1bebe08-31aa8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1bebe08-31aa8.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?