Navigation
Navigation
Section titled “Navigation”Introduction
Section titled “Introduction”The History API provides methods to navigate through the browser’s session history.
Basic Navigation
Section titled “Basic Navigation”// Go back one pagehistory.back();
// Go forward one pagehistory.forward();
// Go back/forward by a number of stepshistory.go(-2); // Go back 2 pageshistory.go(1); // Go forward 1 pagehistory.go(0); // Reload current pageCurrent State
Section titled “Current State”console.log(history.length); // Number of entries in session historySummary
Section titled “Summary”history.back()— navigate to previous pagehistory.forward()— navigate to next pagehistory.go(n)— navigate n steps (negative = back, positive = forward)history.length— number of history entries