SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Nov 2005
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    document.referrer problem

    I have created a web page (web page 1: below) that finds out where the user has been (document.referrer) and puts this value into a text box.
    The name of this textbox is "ReferringSite".

    I have a link
    <a href="new_test.php?ReferringSite">
    which I thought would carry the value of my textbox ReferringSite to the next web page, but alas, it does not.

    How do I do this? I am stumped on this one.



    Web Page 1:
    <html>
    <head>
    <title></title>
    <script language="Javascript">
    function setReferrer()
    { document.Form1.ReferringSite.value = document.referrer; }
    </script>
    </head>

    <body bgColor=aliceblue onload="setReferrer();">
    <form name="Form1">
    <input type=text name="ReferringSite" size=60>
    </form>

    <a href="new_test.php?ReferringSite">
    This does not carry forward value of ReferringSite
    </a>

    </body>
    </html>

    Web Page 2:
    ....
    <html>
    <body>

    <?php
    if (isset($HTTP_GET_VARS['ReferringSite'])) $sTemp = $HTTP_GET_VARS['ReferringSite'];
    print "- $sTemp<br>";
    ?>

    </body>
    </html>

  2. #2
    Maniacally depressed robot poncho's Avatar
    Join Date
    Dec 2004
    Location
    Belfast, N.Ireland
    Posts
    452
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey Kathryn,

    I know this is a javascript forum, but if you're already using PHP, why not just do this?

    Code:
      <input type="text" name="ReferringSite" value="<?php echo $_SERVER['HTTP_REFERER']; ?>">
    Cheers;
    Poncho
    Perfecting the art of breaking stuff.
    Check 'em: CakePHP | TextMate

  3. #3
    SitePoint Addict NikoB's Avatar
    Join Date
    Nov 2005
    Location
    Austria
    Posts
    211
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    <html>
    <head>
    <title></title>
    <script language="Javascript">
    function setReferrer()
    { document.Form1.ReferringSite.value = document.referrer; }
    </script>
    </head>
    
    <body bgColor=aliceblue onload="setReferrer();">
    <form name="Form1" action="new_test.php">
    <input type=text name="ReferringSite" size=60/>
    <input type="submit" value="This does forward value of ReferringSite"/>
    <a href="JavaScript:" onclick="Form1.submit()">this also does forward!</a>
    </form>
    
    <a href="JavaScript:this.location.href='new_test.php?ReferringSite='+document.referer">this is also a way to do this</a>
    
    </body>
    </html>
    i only dont know if the last example escapes correctly, but I think you get the idea...
    Corinis OpenSource Community & Content Management
    http://www.corinis.org


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
  •