JavaScript City

Referrer on Page

Writes the page that referred the viewer to your page onto the page.

Script Code

Grab a copy of the file below and place it in the same directory as the Web page on which you will use the script (if you wish to place the script file in a different directory you will need to make the necessary adjustments to the src attribute of the script tag that calls it).

sdetect2.js

The code below should be placed between the <body> and </body> tags where you want the text to appear.

Example

A working sample of the script is shown below.

Options

You can edit the appearance of the text by adding the doc_ref ID to your style sheet and adjusting as desired.

You can change the message text itself by editing the line below in the sdetect2.js file. Be careful with the variable on the line.

r_span.innerHTML = "You came from "+document.referrer+".";

Accessibility

A server side script, java applet, or plugin may be able to provide the same information as a backup if necessary. Some browsers, firewalls, or other security settings may provide no referrer or an incorrect one, so this is not necessarily going to display the correct information— if any at all.


eXTReMe Tracker