document.referrer

JavaScript 1.0+, JScript 3.0+ Nav2+, IE 4+ Syntax

document.referrer

Description

The referrer property contains the URL of the document that was used to reach the current document. If the URL was typed directly into the browser's location field, this property will be empty.

Example

In Listing 7.158, the referrer property is used to create a link back to the previous document from within the current document in the example.

Listing 7.158 Create a Link Back to the Calling Document Using the referrer Property
<script language="JavaScript">
<!-- Hide

//Create a link back to the referring document.
document.write("<a href='",document.referrer,"'>Go back</a>");

//Hide End --->
</script>
							
						

Get Pure JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.