History back()Method
History Object
Definition and Usage
The back() method loads the previous URL in the history list (if it exists).
The effect of calling this method is equivalent to clicking the back button or calling history.go(-1).
Syntax
history.back()
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the back() method.
Example
Example
Create a back button on the page:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Rookie Tutorial (example.com)</title>
<script>
function goBack(){
window.history.back()
}
</script>
</head>
<body>
<input type="button" value="Back" onclick="goBack()">
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>Rookie Tutorial (example.com)</title>
<script>
function goBack(){
window.history.back()
}
</script>
</head>
<body>
<input type="button" value="Back" onclick="goBack()">
</body>
</html>
The output of the above example is:
Try it yourself »
History Object Other Extensions