Results 1 to 4 of 4

Thread: Javascript Referer....help

  1. #1
    Join Date
    Mar 2006
    Location
    Somewhere....
    Posts
    88
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation Javascript Referer....help

    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

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    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.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Mar 2006
    Location
    Somewhere....
    Posts
    88
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    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.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •