Document.referrer (Property)

The URL of the document that was displayed when the user clicked on a link to request this document.


DOM level - 1
JavaScript - 1.0
JScript - 1.0
Internet Explorer - 3.02
Netscape - 2.0
Opera - 3.0
Property/method value type:String primitive
JavaScript syntax:-myDocument.referrer

The referrer value indicates the page that was being viewed when the user clicked on a link to request this document.

The referrer data is often used in log analysis to trace a click stream that the user traversed your web site with. This property allows you to do similar things at the client end and build all kinds of history trees and back button simulations.

If you are prepared to do a little work to dismantle the referring link, you can detect when someone has a link to one of your internal pages. What you do then is up to you but you could redirect to an error page or simply bump the user to your front page. This would mean that whatever they did to bookmark one of your pages, they would always end up at your front door instead.


See also:Document object, Document.lastModified, Document.location, Document.URL, Window.location

Property attributes: