How do I get the URL of previous page in JavaScript?
Say, I go from page A to B, and use browser back button to go back to page A.
I've tried to use history.previous, but I'm can't get it to work.
If you want to go to the previous page without knowing the url, you could use the new History api. history. back(); //Go to the previous page history. forward(); //Go to the next page in the stack history.go(index); //Where index could be 1, -1, 56, etc.
You have to store in session. app. get('/url1', function(req, res){ res. send('ok') req.
The referrer property returns the URL of the document that loaded the current document. The referrer property is read-only.
You can use the following to get the previous URL.
var oldURL = document.referrer; alert(oldURL);
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