How can I get the URL from history.go (-2)

I have a question, is it possible to get url from history.go (-2)? Assuming I don’t know this URL.

change

I need a URL because I want to check where the visitor was redirected from. There are two cases: 1 facebook, 2 directly on the website. the second step is automatic user verification. The third step is a mistake, but if I go back to step 1. I can get around the error. with everything that works fine. the problem is that I don’t know where to redirect (being two forwarders).

+4
source share
5 answers

For reasons of immunity he is not.

+6
source

You may in some special cases get the previous URL from history.previous (as well as for .current and .next ), but you cannot look back arbitrarily and see where I (the visitor) went two, three or 10 pages back. It’s never guaranteed to get even the latest page URL (sometimes available as a “referent”) from a website.

Thinking about it from the perspective of your visitor is good. Just because I visit your site does not mean that I want you to know about every other page I have ever visited in the same browser window.

+4
source

No, not in general.

If the URL is on the same host name as the current page, which you can sort by opening the popup, moving backward 2, and then using the script in the popup to read opener.location , go ahead 2 and pass the URL script address in opener . But that would be a huge pain and rather unreliable.

If the URL does not refer to the same host name, you cannot at all, for privacy reasons.

+2
source

I'm not sure if this is possible with your setup, but you can add a GET believably (i.e. page.ext?ref=1 ) and then save this in a session and output it to any page you need. Then, on your facebook page, you can add ?ref=1 to the link. This will allow you to add other links to sites in the future.

+1
source

Perhaps this is not possible since history.go() redirects the URL.

You can get the previous / next URL by executing the history.previous / history.next property respectively. This returns you an absolute URL. For the current URL, use history.current .

Additional information about the story object.

-1
source

All Articles