faqts : Computers : Programming : Languages : JavaScript : Document

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

63 of 81 people (78%) answered Yes
Recently 9 of 10 people (90%) answered Yes

Entry

How can I redirect people based on the page they came from?
Can I create a page that only accepts links from one other page?

Feb 23rd, 2000 20:39
Nathan Wallace, Martin Honnen


With client side javascript you can check

  document.referrer

for the page the visitor comes from. So

  <SCRIPT>
  var mainURL = 'http://yourMainPageURLhere';
  if (document.referrer != mainURL)
    top.location.href = main.URL;
  </SCRIPT>

There are server side methods too to assist you with that task.

Be careful though because the referer passed by the browser is not
always reliable.