History forward() Method
THE WORLD'S LARGEST WEB DEVELOPER SITE

History forward() Method

❮ History Object

Example

Create a forward button on a page (This example will not work if the next page does not exist in the history list):

<button onclick="goForward()">Go Forward</button>

<script>
function goForward() {
    window.history.forward();
}
</script>

The output of the code above will be:

Try it Yourself »

Definition and Usage

The forward() method loads the next URL in the history list.

This is the same as clicking the "Forward button" in your browser, or history.go(1).

Note: This method will not work if the next page does not exist in the history list.

Tip: To load the previous URL in the history list, use the history.back() method.


Browser Support

Method
forward() Yes Yes Yes Yes Yes

Syntax

history.forward()

Parameters

None

Technical Details

Return Value: No return value

❮ History Object