1

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
  • 764
  • 3
  • 11
  • 25

2 Answers2

2

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,721
  • 20
  • 26
0

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

piterio
  • 720
  • 1
  • 5
  • 23