JavaScript Window History code example
Example 1: js window history
window.history.back()
window.history.forward()
window.history.go(-2)
window.history.go(0)
window.history.go()
let numberOfEntries = window.history.length
Example 2: JavaScript Window History
<html>
<head>
<script>
function goBack() {
window.history.back()
}
</script>
</head>
<body>
<input type="button" value="Back" onclick="goBack()">
</body>
</html>
Example 3: window.history
var newurl = window.location.protocol + "//" + window.location.host + window.location.pathname + '?newParameter=1';
window.history.pushState({ path: newurl }, '', newurl);