How to get previous page URL using jQuery?
I am using the following code to get the current page location
$(document).ready(function() { var pathname = window.location.pathname; });
Easy as pie. $(document). ready(function() { var referrer = document. referrer; });
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.
Easy as pie.
$(document).ready(function() { var referrer = document.referrer; });
Hope it helps. It is not always available though.
Do you mean something like history.go(-1);
? It will go back to the previous page.
window.history on MDN
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