Document.referrer

  • Revision slug: Web/API/document.referrer
  • Revision title: document.referrer
  • Revision id: 472001
  • Created:
  • Creator: Prachi_Dighe
  • Is current revision? No
  • Comment

Revision Content

{{DomRef}}

Summary

Returns the URI of the page that linked to this page.

Syntax

string = document.referrer; 

Notes

The value is an empty string if the user navigated to the page directly (not through a link, but, for example, via a bookmark). Since this property returns only a string, it does not give you DOM access to the referring page.

Specification

Revision Source

<div>
  {{DomRef}}</div>
<h2 id="Summary" name="Summary">Summary</h2>
<p>Returns the <a href="http://www.w3.org/Addressing/#background">URI</a> of the page that linked to this page.</p>
<h2 id="Syntax" name="Syntax">Syntax</h2>
<pre class="syntaxbox">
<var>string</var> = document.referrer; 
</pre>
<h2 id="Notes" name="Notes">Notes</h2>
<p>The value is an empty string if the user navigated to the page directly (not through a link, but, for example, via a bookmark). Since this property returns only a string, it does not give you DOM access to the referring page.</p>
<h2 id="Specification" name="Specification">Specification</h2>
<ul>
  <li><a href="http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-95229140">DOM Level 2: referrer</a></li>
</ul>
Revert to this revision