View Full Version : trouble with Referrer Checker script

02-23-2003, 10:19 PM
Have tried this script on a site I have,

/*Referrer Checker- By JavaScript Kit
(www.javascriptkit.com) Over 200+ free JavaScripts here!

//specify valid referrals for script to accept
//if you wish an entire domain to be valid, enter that (ie: "javascriptkit.com")
var validreferrals=new Array()

var passed=0

for (r=0;r<validreferrals.length;r++){
if (document.referrer.indexOf(validreferrals[r])!=-1){

if (passed==0){
alert("Access to the page denied!")


Problem I am having is that if i want the entire domain to be valid
ie. http://myname.sharewith.us

It wont work, could this be anything to do with the webspace i am using? It is a freebie!

The reason i am using this is that i have a password protected section of a website, i dont want anyone typing a page url into the browser and bypassing it.

Any help appreciated, thanks,
PS I am not into scripts at all!

02-24-2003, 08:06 AM
not sure what you are trying to accomplish really, as I just used the refferer property and it worked fine...

where is the link located that goes to your members page?....the referrer is the page you 'just' came from....its where the link resides that got you to the page you're at...does that make sense?

where is your site, and I"lll check it out.

---> actually, I just looked at the script...it uses the "indexOf" property which doesn't use an exact match...it only checks to see if the referrer contains the given string...so, if you had...


and you were testing it against say,

it would match.....

02-24-2003, 09:21 AM
Just looking at my pages, Im wondering if its actually the password protection thats confusing the script?
I am using atompark webpage password protector. It basically seems to change the index.htm file to index.htm.bak, and creates the password page as index.htm

If i use index.htm or index.htm.bak as the referrer page things dont work, however if a member logs in and i then send them to an index2.htm and use this page as the refferer it works ok.

The only problem I then have is that someone could bypass the front door by typing the index2.htm addy in the address bar.

Hope I havent confused you as much as ive confused myself;)