history javascript

Solutions on MaxInterview for history javascript by the best coders in the world

showing results for - "history javascript"
Muhammad
10 Mar 2016
1// Should be null because we haven't modified the history stack yet
2console.log(`History.state before pushState: ${history.state}`);
3
4// Now push something on the stack
5history.pushState({name: 'Example'}, "pushState example", 'page3.html');
6
7// Now state has a value.
8console.log('History.state after pushState: ', history.state);
Micheal
28 Sep 2018
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