Web Analytics Made Easy -
StatCounter access to pages - CodingForum

Announcement

Collapse
No announcement yet.

access to pages

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new 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
    hi,

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

    Comment


    • #3
      Thanks! Does anyone else out there possibly have a coding example for me?

      Comment


      • #4
        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. ;)

        Comment


        • #5
          Thanks so much! I will give it a try tomorrow!

          Comment

          Working...
          X