js window history

Solutions on MaxInterview for js window history by the best coders in the world

showing results for - "js window history"
Warren
02 Jan 2019
1// go back:
2window.history.back()
3// go forward:
4window.history.forward()
5// go to specific point:
6window.history.go(-2) // go back 2 pages, 0 is current page
7window.history.go(0) // refreshes current page
8window.history.go() // refreshes current page
9// get number of pages in history
10let numberOfEntries = window.history.length
11
Ariana
05 Sep 2020
1var newurl = window.location.protocol + "//" + window.location.host + window.location.pathname + '?newParameter=1';
2window.history.pushState({ path: newurl }, '', newurl);
Emmanuel
05 Feb 2017
1<html>
2<head>
3<script>
4function goBack() {
5  window.history.back()
6}
7</script>
8</head>
9<body>
10
11<input type="button" value="Back" onclick="goBack()">
12
13</body>
14</html>