CKTIS / JavaScript
history.forward() — move forward through history
history.forward() moves one entry forward through browser session history. It behaves like history.go(1); without a next entry, it changes nothing.
Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support
Syntax
history.forward()history.forward() takes no arguments and returns undefined, not a Promise. It behaves like history.go(1): it requests traversal to the next session history entry. That entry may belong to the same document or another page; the method does not create an entry.
Traversal is asynchronous. Do not read the new history.state immediately after calling it. In the example, popstate events synchronize traversal between same-document entries. pushState() itself does not fire popstate.
Without a next entry, nothing happens. A document that is not fully active causes SecurityError; the browser may also block the navigation request. This is a browser API defined by HTML, not an ECMAScript feature; having Node 24 does not establish support. The standard indicates support in all current browser engines.
Examples
const button = document.createElement('button');
button.textContent = 'Run history demo';
document.body.append(button);
button.addEventListener('click', () => {
button.disabled = true;
history.pushState({ step: 1 }, '');
history.pushState({ step: 2 }, '');
window.addEventListener('popstate', () => {
console.log(history.state.step);
window.addEventListener('popstate', () => {
console.log(history.state.step);
button.remove();
}, { once: true });
history.forward();
}, { once: true });
history.back();
}, { once: true });Result
1 2
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.