Jump to content

Get URL of last page visited?


SifJar

Recommended Posts

Hi there. I was wondering if there is anyway to get the last page viewed in Javascript? I know there is document.referrer, but that only works if the last page linked to the current one, which won't work for what I'm trying to do. I want to get the URL of the last page in history. I know you can go back to the last page using history.go(-1), but is there a way to get the actual URL?Failing this, is there anyway to do this, using another web technology e.g. another scripting language, that is reasonably widely supported?Thanks for your help.

Link to comment
Share on other sites

What do you want to do anyway? There could be another method to achieve your goal.

Link to comment
Share on other sites

i figured that may be the case...what about loading the last page in an iframe or something?
trying to run javascript functions on last page visited. kinda like a bookmarklet, but run by opening a html document if you understand.
Link to comment
Share on other sites

trying to run javascript functions on last page visited. kinda like a bookmarklet, but run by opening a html document if you understand.
You can't do that for security reasons. If you could do that, you could alter the last page, then show the altered version to the user, potentially tricking him into giving you some data that was intended for the other site. Even if that's not what YOU are doing, there are others who will.If you want to do something on an arbitrary page, you MUST prompt the user to specify it.
Link to comment
Share on other sites

get the url of just the last previous page? of your domain only, or all previous pages? of yours and external domains?if you require last previous page, of your domain only, would storing url in javascript cookie work?one cookie to store previous url, and another to store current, then next page, the current would become the previous.

Link to comment
Share on other sites

You can't do that for security reasons. If you could do that, you could alter the last page, then show the altered version to the user, potentially tricking him into giving you some data that was intended for the other site. Even if that's not what YOU are doing, there are others who will.If you want to do something on an arbitrary page, you MUST prompt the user to specify it.
Yeah I realise the security risk, didn't really think too much about it...Pity.
get the url of just the last previous page? of your domain only, or all previous pages? of yours and external domains?if you require last previous page, of your domain only, would storing url in javascript cookie work?one cookie to store previous url, and another to store current, then next page, the current would become the previous.
No, not of any specific domain. The idea was to get the last page viewed of all pages.I was trying to make a sort of bookmarklet workaround for the PSP, where you cannot bookmark "java script:" addresses (even if you manually add them, it doesn't show them).
Link to comment
Share on other sites

I always get a little leary when I see someone asking for code that can be used for ID theft, bank account information, passwords, basically something that has 100 bad uses and not really any good ones. I would just drop this line of thinking and play with your PSP and be happy. If you are looking for places you have been, check your history. If you are looking for places other people have been, if they wanted you to know they would tell you.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...