Detecting forward and back button clicks uses a similar technique to that used for specific URLs. When either of these buttons is clicked, a popstate
event is triggered. The history.js
script listens for popstate
events and, when one occurs, it triggers a changestate
event. From this point forward, the process is the same. The router detects the changestate
event and manages the response.