Philipp Werminghausen
Philipp Werminghausen

Reputation: 1152

can I check what site window.history.back() will bring the user to?

in one of my webpages I want to send the user back to the previous page after some computation, but only if the previous page was a page from my website.

So I am wondering if there is an easy way to check that?

Thank you for any input!

Upvotes: 2

Views: 6305

Answers (2)

rolfv1
rolfv1

Reputation: 571

You can however check how you arrived at the current page by using 2 methods:

document.referrer, but that only works if the user didn't block that, and gives you some limited info. A more robust method might be to set some information about the previous page in either the URL, or in a SESSION variable.

Upvotes: 4

jbabey
jbabey

Reputation: 46657

No.

For security reasons the History object doesn't allow the non-privileged code to access the URLs of other pages in the session history, but it does allow it to navigate the session history.

Documentation

Upvotes: 3

Related Questions