Sreejesh T S
Sreejesh T S

Reputation: 119

How to get a referrer URL on Angular 4?

How to get a referrer URL on Angular 4?? For example say example.com is my angular website, if example.com is visited from an another php page say domaintwo.com/checkout.php. How can I identify the the referenced url(domaintwo.com/checkout.php) from my angular website..?? Am looking for a solution like $_SERVER['HTTP_REFERER'] on PHP(same process needed on angular4). Thanks in Advance

Upvotes: 7

Views: 15480

Answers (1)

Mike Doe
Mike Doe

Reputation: 17604

Have you tried?

document.referrer

According to W3C:

referrer of type DOMString, readonly

Returns the URI [IETF RFC 2396] of the page that linked to this page. The value is an empty string if the user navigated to the page directly (not through a link, but, for example, via a bookmark).

Upvotes: 15

Related Questions