2

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.

Shrinivas
  • 824
  • 4
  • 12
  • 26

2 Answers2

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
0

Maybe you can have some kind of solution saving the document.referrer using localStorage each time you need.

piterio
  • 760
  • 1
  • 6
  • 23