HTML DOM referrerProperty

Document 对象参考手册Document Object

Definition and Usage

The referrer property returns the URL of the document that loaded the current document.

If the current document is not accessed via a hyperlink, it is null. This property allows client-side JavaScript to access the HTTP referrer header.

Syntax

document.referrer


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the referrer property.


Example

Example

Return the source URL of the current document:

<html>
<body>

The referrer address of this document:
<script>
document.write(document.referrer);
</script>

</body>
</html>

Try it Yourself »


Document 对象参考手册Document Object Other Extensions