Latest web development tutorials

History go () method

History Object Reference History Object

Definition and Usage

go () method can be loaded from the history list a specific page.

This parameter can be a number, use the relative position of the URL to access the URL in the History list. (-1 On a page, a page 1 forward). Or a string, the string must be a partial or complete URL, the function will go to the first match a URL string.

grammar

history.go(number|URL)


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support go () method


Examples

Examples

Click to return to the previous two pages:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
<script>
function goBack(){
    window.history.go(-2)
}
</script>
</head>
<body>

<input type="button" value="后退2页" onclick="goBack()">

</body>
</html>

Examples of the above output:


try it"


History Object Reference History Object