Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5

Thread: access to pages

  1. #1
    New to the CF scene
    Join Date
    Jun 2002
    Location
    Midwest
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    access to pages

    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!

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Posts
    117
    Thanks
    0
    Thanked 0 Times in 0 Posts
    hi,

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

  • #3
    New to the CF scene
    Join Date
    Jun 2002
    Location
    Midwest
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks! Does anyone else out there possibly have a coding example for me?

  • #4
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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)

    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #5
    New to the CF scene
    Join Date
    Jun 2002
    Location
    Midwest
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks so much! I will give it a try tomorrow!


  •  

    Posting Permissions

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