Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the previous page URL using JavaScript? [duplicate]

Tags:

javascript

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.

like image 854
Gaglad Avatar asked Apr 26 '11 08:04

Gaglad


People also ask

How can I see previous pages in Javascript?

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.

How do I find the previous URL in node JS?

You have to store in session. app. get('/url1', function(req, res){ res. send('ok') req.

What is document referrer in Javascript?

The referrer property returns the URL of the document that loaded the current document. The referrer property is read-only.


1 Answers

You can use the following to get the previous URL.

var oldURL = document.referrer; alert(oldURL); 
like image 109
Ammu Avatar answered Sep 24 '22 07:09

Ammu