Is there any way to get the previous URL in JavaScript? Something like this:
alert(\"previous url is: \" + window.history.previous.href);
document.referrer
is not the same as the actual URL in all situations.
I have an application where I need to establish a frameset with 2 frames. One frame is known, the other is the page I am linking from. It would seem that document.referrer
would be ideal because you would not have to pass the actual file name to the frameset document.
However, if you later change the bottom frame page and then use history.back()
it does not load the original page into the bottom frame, instead it reloads document.referrer
and as a result the frameset is gone and you are back to the original starting window.
Took me a little while to understand this. So in the history array, document.referrer
is not only a URL, it is apparently the referrer window specification as well. At least, that is the best way I can understand it at this time.