I know I access browser history using history
object, specifically, I can use history.back();
, history.forward();
and history.go(item-number)
(or history.go(url)
). What I am trying to determine where in the browser history the user currently is.
Firefox, for example, may support accessing individual url's from the history, but that's not what I'm after, because the history of 20 url's may contain repeated url's.
Note that I am not interested in a history within my project - but rather browser history within any user's session.
For example, a user opened the browser and went through 20 pages - so the history contains 20 objects. Then the user hit back button 4 times - and ended up on the 16th of the 20 pages (or rather 15th of the 0..19 pages). Is there any way to get this current offset (16 or 15) using JavaScript? If yes, then how?
history.length
returns the length of the current history.
sadly there is no method to figure out where in it you are.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With