tej
tej

Reputation: 1

How to know from which website we were redirected to

I have a back button on my application. When users come from another domain to mine. How can I know from which URL user landed on my application?

I would like to redirect the user to the URL they have come with when they click on my "Go back` button.

Thanks

Upvotes: 0

Views: 235

Answers (2)

Ghayyour Ahmed Butt
Ghayyour Ahmed Butt

Reputation: 393

There are couple of ways for doing that 1. By using document var prevURL = document.referrer;

  1. by using Window window.history.back();

Upvotes: 0

str
str

Reputation: 44969

You don't need to replicate the browser's functionality as they already do that perfectly fine.

But if you really want to, you can just use history.back(). And if you really really want to know where the user came from, you can use document.referrer.

Upvotes: 1

Related Questions