files/en-us/web/api/history/go/index.md
{{APIRef("History API")}}
The go() method of the {{domxref("History")}} interface loads a specific page from the
session history. You can use it to move forwards and backwards through the history
depending on the value of a parameter.
This method is {{glossary("asynchronous")}}. Add a listener for the {{domxref("Window/popstate_event", "popstate")}} event in order to determine when the navigation has completed.
go()
go(delta)
delta {{optional_inline}}
history.go(2) moves forward two pages and history.go(-2)
moves back two pages. If no value is passed or if delta equals 0, it has
the same result as calling location.reload().None ({{jsxref("undefined")}}).
SecurityError {{domxref("DOMException")}}
To move back one page (the equivalent of calling {{domxref("History.back", "back()")}}):
history.go(-1);
To move forward a page, just like calling {{domxref("History.forward", "forward()")}}:
history.go(1);
To move forward two pages:
history.go(2);
To move backwards by two pages:
history.go(-2);
And finally, either of the following statements will reload the current page:
history.go();
history.go(0);
{{Specifications}}
{{Compat}}