Join the AI Workshop to learn more about AI and how it can be applied to web development. Next cohort February 1st, 2026
The AI-first Web Development BOOTCAMP cohort starts February 24th, 2026. 10 weeks of intensive training and hands-on projects.
We use the methods:
back()forward()go()
Let’s start with the simplest thing you can do with the History API.
Go back to the previous page:
history.back()
this goes to the previous entry in the session history. You can forward to the next page using
history.forward()
This is exactly just like using the browser back and forward buttons.
go() lets you navigate back or forward multiple levels deep. 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) //equivalent to calling history.forward() 3 times
To know how many entries there are in the history, you can call
history.length