View Full Version : Javascript Referer....help
Samsoske
06-05-2006, 03:36 PM
Hi there.
I am working on something and was woundering if any of you know a javascript that only allow's access to a page on your site - coming from a specific page on your site. And thus it blocks you from typing it into the Addess bar/redirects you...
I know i have witnessed this script in action a long time ago on a website. But i was stupid enough to forget to save the code somewhere. So if anyone could help i would be SUPER SUPER greatfull!
Thanks in advance...
Samsoske:D
djr33
06-05-2006, 04:54 PM
You might want to do something like this, aka related to security, with php instead.
I believe that the variable may be $HTTP_REFERER in php...
<?php if ($HTTP_REFERER != "http://yoursite.com/yourpage.htm") { die('error');} ?>
With that at the top of your page, the rest below. You could use a redirect tag instead of 'error', etc.
this is untested. I'm not really sure why/what you are doing specifically... so look into it more at php.net if you want to use this.
I'm not sure how it works in javascript.
I suppose you could check their history. I'm just unsure if javascript has access to the referer... that's more server side... but it probably does.
Samsoske
06-05-2006, 06:46 PM
Thinking bad far enough it might have been java or an HTML element(dought that) but it was only two lines long, and typing it in note pad on came up about this size
-----------------------------------
| |
| |
-----------------------------------
of writing- Yeah so right nw i am pretty stumpd...?
But thanks for the help with PHP- djr33 (nice signature:))
Bb,
Samsoske
I'm just unsure if javascript has access to the referer... that's more server side... but it probably does.It does. window.document.referrer is the property.
However, you should never rely upon the referrer header (either the window.document.referrer Javascript property or the Referer: HTTP header) as some firewalls will strip it.
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.