Javascript examples for Browser Object Model:History
The go() method loads a specific URL from the history.
Parameter | Description |
---|---|
number|URL | Required. |
If the parameter is number, it goes to the URL within the specific position (-1 goes back one page, 1 goes forward one page).
If the parameter is a string. The function will go to the first URL that matches the string.
No return value
The following code shows how to Click on the button to go back two pages:
<!DOCTYPE html> <html> <body> <button onclick="goBack()">Load the next URL in the history list</button> <script> function goBack() {/*from w w w . j ava 2 s . c o m*/ window.history.go(2); } </script> </body> </html>