Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
92
rated 0 times [  95] [ 3]  / answers: 1 / hits: 50970  / 12 Years ago, fri, august 17, 2012, 12:00:00

I am on page A.



Now I click in page A and redirected to page B.
Now I click in page B and redirected to page A.



Here i want to know the url of page B.



I have tried document.referrer but its not working.


More From » url

 Answers
4

document.referrer works when a user clicks on a link to navigate to the current page but I don't think it works when you do a manual redirect in a Javascript function.



The only way I can think of is to store the URL of the page before the user is redirected to your current page.



You could store it in a hidden form or a cookie.



This question has also been asked before and its worth having a quick read through here. How do you get the previous url in Javascript?



I took this cookie example from it to show you what I mean.



$.cookie(previousUrl, window.location.href, {path:/});

[#83579] Thursday, August 16, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
aileent

Total Points: 556
Total Questions: 107
Total Answers: 101

Location: Croatia
Member since Fri, Sep 11, 2020
4 Years ago
;