Venelin
Venelin

Reputation: 3308

Getting the URL which redirected to this page

In this code:

if (screen.width <= 800) {
    window.location = "http://www.megaoferta.bg/mobile";
}

How can I identify the URL from whom the page is opened with JavaScript?

For example, if people get to my page from a Google search, how can I obtain the page "google.com" using JavaScript?

Upvotes: 0

Views: 108

Answers (1)

SeanLF
SeanLF

Reputation: 131

You can use the document referrer:

var x = document.referrer;

Upvotes: 6

Related Questions