stumped on referrer script

i am trying to get a script that will work accross all major browsers, that will limit access to pages by referring page.

specifically, one that will not load if the referring page is null or opened in a browser (no referrer), and that wont open if they dont come from a page i specify ....  maybe with a popup message for error and something like that

maybe even having a cookie from the referring page checked by the script access page, in case the referring page idea isnt completely foolproof .


things along those lines ... jsut trying to secure my domain =)

thanks =)
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

<script langauge="JavaScript" type="text/javascript">
if(document.referrer != "")
      alert("You do not have access to this page.")
      parent.window.location = ""

This script will check if you came from a specific URL, if not it will popup and error message and redirect you.

Change to the only site that the user can view the page from. Change to the page you want to redirect to if they don't come from the proper URL.
sanctifyAuthor Commented:
ok ..what if there are multiple pages a user can come from ????

instead of redirecting is there a way to jsut loop it so they go nowhere  ?  
Loop what? Loop the error message?
Rowby Goren Makes an Impact on Screen and Online

Learn about longtime user Rowby Goren and his great contributions to the site. We explore his method for posing questions that are likely to yield a solution, and take a look at how his career transformed from a Hollywood writer to a website entrepreneur.

Here's a modified version that allows multiple URLs:

<script langauge="JavaScript" type="text/javascript">
var allowed = false
var validURL = new Array()

validURL[0] = ""
validURL[1] = ""
validURL[2] = ""

      if(document.referrer == validURL[i])
      allowed = true

      alert("You do not have access to this page.")
      window.location = ""

You can add as many validURL's as you want:
validURL[3] = ""
validURL[4] = ""

If the referrer is not in the validURL array, it will display an error.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sanctifyAuthor Commented:
by looping i mean going nowhere .. keeping a blank page, ignoring all other script ... going nowhere

sanctifyAuthor Commented:
or wait ... looping the script would be good ..then if they access it they would ahve to  delete the iexplorer.exe from the task manager to get out of it .... how do i do that ?

by the way ..thank you !!!!!!!!!!!!!!!!!!!!!!
sanctifyAuthor Commented:
maybe i could have a few options of both to use ... ill increase the points ...hold on ...thanks again ... you are teaching me alot !!!!!!!!!
sanctifyAuthor Commented:
there now its at 1`40 instead of 85 !
sanctifyAuthor Commented:
the script u gave me isnt working ...

it gives me the error even if im coming from the valid page ...thank you !
sanctifyAuthor Commented:
wait no .. i copied it wrong .. its working WOOOHOOOOO

THANKS !!!!!!!!!!!!!!!!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Languages and Standards

From novice to tech pro — start learning today.