0

I have implemented a previous button on my page, which navigates me back to the previous page.

i.e, Page A -> Page B (has previous button) How Can I find the link of Page A so that it will take me back to Page A using javascript/jQuery

I tried this link

How to get the previous URL in JavaScript?

I used this history.back() but that works with onclick

How to get href.

summu
  • 388
  • 2
  • 7
  • 25

1 Answers1

0

Use document.referrer:

console.log(document.referrer);
/* The above logs this page because Stack Snippets are run on stacksnippets.net,
   and therefore your browser went there from this page 
   (because you're running the code here).
*/
Jack Bashford
  • 43,180
  • 11
  • 50
  • 79