Join the AI Workshop and learn to build real-world apps with AI. A hands-on, practical program to level up your skills.
The History API provides these methods:
back()forward()go()
To go back to the previous page:
history.back()
This navigates to the previous entry in the session history. To go forward to the next page:
history.forward()
This is the same as using the browser back and forward buttons.
go() lets you move back or forward by multiple steps. For example:
history.go(-1) // equivalent to history.back()
history.go(-2) // equivalent to calling history.back() twice
history.go(1) // equivalent to history.forward()
history.go(3) // same as calling history.forward() three times
To get the number of entries in the history:
history.length