The Window.history object does not use Window's prefix when writing. In order to protect user privacy, it has limited the method of JavaScript accessing the object.
method:
History.back () -The first URL in the historical list, which is the same
History.Forward () -The next URL in the historical list, which is the same
Example:
Copy code code as follows:
<html>
<button name = "back" value = "back" onClick = "goback ()"> back </Button>
<button name = "forward" value = "forward" onClick = "goforward ()"> forward </Button>
<script type = "text/javascript">
Function GOBACK () {
history.back ();
}
function goforward () {
hestory.Forward ();
}
</script>
</html>
Other methods:
Copy code code as follows:
History.go (0); // Refresh the current page
// The following is a historical record in the browser, otherwise it will not be effective.
history.go (1); // forward one page
History.go (-1); // back a page back
History.go (-2); // back two pages back
History.Length; // The number of historical records contained in the current window