window.history

window.history allows limited access to the previously-visited pages in the same browser session.

For example, you can see how many pages the user has visited before coming to your page. You cannot see the actual URLs though for privacy reasons this doesn't work.

window.history.length //output:5

To navigate back and forth through the user's session as if the user had clicked the Back/Forward browser buttons.

history.forward()
history.back()

To skip pages back and forth with history.go(). This is same as calling history.back():

history.go(-1);
history.go(-2); //Two pages back
history.go(0); //Reload the current page
History Object Properties
PropertyDescription
lengthReturns the number of URLs in the history list
History Object Methods
MethodDescription
back()Loads the previous URL in the history list
forward()Loads the next URL in the history list
go()Loads a specific URL from the history list
Related Tutorial
Follow Us
https://www.facebook.com/Rookie-Nerd-638990322793530 https://twitter.com/RookieNerdTutor https://plus.google.com/b/117136517396468545840 #
Contents +