The history object contains the URLs visited by the user (within a browser window). How do I view the visited URLs? I tried consoling the object and checked through all the fields, couldn't find the required data. history.back() will load the previous, but I just want to know the previous URL.
Asked
Active
Viewed 3,590 times
2 Answers
3
You cannot do this.
It's made for security reasons.
However you can view the last one (page which you came from) by checking document.referrer
.
See more here

Romko
- 1,808
- 21
- 27
-
Is there any other way to get the history? (I know I can manually stack up the URLs using location.href) – Shrinivas Oct 27 '15 at 12:42
-
nope as far as i know, but look at solution below from @piterio – Romko Oct 27 '15 at 15:19
-
If it's a security reason why you are allowed to manipulate the history stack ? – Ridan Nov 30 '17 at 19:43
0
Maybe you can have some kind of solution saving the document.referrer
using localStorage
each time you need.

piterio
- 760
- 1
- 6
- 23