Javascript Reference - History back() Method








The back() method loads the previous URL in the history list.

Browser Support

back Yes Yes Yes Yes Yes

Syntax

history.back()

Parameters

None.

Return Value

No return value.





Example

The following code shows how to Create a back button on a page.


<!DOCTYPE html>
<html>
<head>
<script>
function goBack() {<!--  w w  w  .ja va  2  s  .  c  o m-->
    window.history.back()
}
</script>
</head>
<body>
<button onclick="goBack()">Go Back</button>
</body>
</html>

The code above is rendered as follows: