history.go(url/number)
The go() method can navigate through the user's history backward or forward. go() accepts an integer representing the number of pages to go backward or forward a its single argument.
A negative number moves backward in history and a positive number moves forward.
//go back one page
history.go(-1);
//go forward one page
history.go(1);
//go forward two pages
history.go(2);
<!DOCTYPE HTML>
<html>
<head>
<title>Example</title>
</head>
<body>
<script>
history.go(-1);
</script>
</body>
</html>
The go() method argument can be a string. The browser navigates to the first location in history that contains the given string.
The closest location may be either backward or forward. If there's no entry in history matching the string, then the method does nothing:
<!DOCTYPE HTML>
<html>
<head>
<title>Example</title>
</head>
<body>
<script type="text/javascript">
window.history.go("http://www.java2s.com");
</script>
</body>
</html>