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

Sreejesh T S
  • 89
  • 2
  • 4
  • 12

1 Answers1

11

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).

Mike Doe
  • 16,349
  • 11
  • 65
  • 88
  • 4
    note that a referal from HTTPS > HTTP doesn't provide the referrer to you https://stackoverflow.com/questions/16551586/can-you-at-least-get-the-domain-of-the-https-referer – Simon_Weaver Jun 15 '19 at 01:26