History go() Method - Javascript Browser Object Model

Javascript examples for Browser Object Model:History

Description

The go() method loads a specific URL from the history.

Parameter Values

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.

Return Value:

No return value

The following code shows how to Click on the button to go back two pages:

Demo Code

ResultView the demo in separate window

<!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>

Related Tutorials