PDA

View Full Version : access to pages



nerdgrrl
Jun 17th, 2002, 09:22 PM
I am looking for a script that will only let a user access a certain page if they came FROM a designated other page. Is that possible?

Thanks!

bpaulsen2000
Jun 17th, 2002, 09:40 PM
hi,

don't have a sample for your right now, but what you're looking
for is the window.referrer function.

nerdgrrl
Jun 18th, 2002, 12:58 AM
Thanks! Does anyone else out there possibly have a coding example for me?

whammy
Jun 18th, 2002, 01:30 AM
Keep in mind that It's not totally reliable - for instance it won't work if they access your page directly (from a bookmark, for example), since there will not be a referrer in that case. However, you did ask for an example!:

<script language="JavaScript" type="text/javascript">
<!--
var thereferrer = document.referrer;
if(thereferrer != "http://www.mysite.com/myreferringpage.html"){
window.location = "http://www.barbie.com";
}
// -->
</script>

If you're not sure what the document.referrer IS, you can type this in the address bar (it should even work right here, right now...)!

javascript:alert(document.referrer)

:)

nerdgrrl
Jun 18th, 2002, 04:22 AM
Thanks so much! I will give it a try tomorrow!:D