For example, you might’ve opened a link from the result of Google search engine (SERPs). Now if in the loaded document we call this property, the URL of the Google which is “https://www.google.com” will return because this is the source where the currently loaded document is coming from.
document referrer Property Syntax:
document referrer Property Input Value
The property is read-only and so we can’t assign a value to it.
document referrer Property Return Value
The return value of this property is the URL of the source document where the currently loaded document is coming from.
Note: if users directly put the URL of a document in a browser, then calling this property on such documents will return an empty string!