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
  1. #1
    New to the CF scene
    Join Date
    Jan 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Trouble setting document.referrer from Firefox

    I need to get document.referrer specified in order to have visits from our site recognized on another site. The problem is that our links are in a Java applet that pops up new browser windows. As a result, the destination site gets blank document.referrer information.

    With Internet Explorer the workaround is simple because one can use a re-direct page that gets the destination URL specified in the query string and triggered by onload it extracts the destination URL and uses click() to go to it, thus setting the re-direct page as the referrer.

    With Firefox this doesn't work, apparently because click() is disabled for security reasons.

    Is there some way to get document.referrer information set? The best I've been able to do so far is have code that works as desired for Internet Explorer and refers to a different page for Firefox users, where the user needs to click a browser button explicitly to get to the destination site.

    Is there some way to get this working without the user having to click a button?

    The code that works for Internet Explorer and refers to another page for Firefox is:

    <html>
    <head>
    <SCRIPT>
    function clickTo()
    {
    document.links[0].href=document.location.search.substring(1);
    document.links[0].click();
    }
    </SCRIPT>
    </head>
    <body onload="clickTo();">
    <script>
    if (navigator.appName.indexOf("Microsoft") < 0) location.replace("button.html" + document.location.search);
    </script>
    <form>
    <a href="something.html"><input type=hidden onclick="clickTo();"></a>
    </form>
    </body>
    </html>

  • #2
    Senior Coder
    Join Date
    Oct 2008
    Location
    Long Beach
    Posts
    1,196
    Thanks
    36
    Thanked 164 Times in 164 Posts
    You should be passing a tracking variable. document.referrer is an outdated and as you can see, an unreliable, method of tracking.
    Feel free to e-mail me if I forget to respond ;)
    ohsosexybrit@gmail.com

  • #3
    New to the CF scene
    Join Date
    Jan 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by itsallkizza View Post
    You should be passing a tracking variable. document.referrer is an outdated and as you can see, an unreliable, method of tracking.
    By "tracking variable" do you mean something like a variable that I pass in the query string? That was my backup plan, but the folks who run the other site sound like they typically do tracking using document.referrer.

  • #4
    Senior Coder
    Join Date
    Oct 2008
    Location
    Long Beach
    Posts
    1,196
    Thanks
    36
    Thanked 164 Times in 164 Posts
    URL appendation is the most common way, especially if you're using some sort of tracking software (or they are).
    Feel free to e-mail me if I forget to respond ;)
    ohsosexybrit@gmail.com

  • #5
    New to the CF scene
    Join Date
    Jan 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I found that Firefox and Internet Explorer treat referrer information after "location.replace" differently, so the following code seem to work for referring seamlessly and adding referrer information in Internet Explorer, Firefox, Safari and Chrome.

    <html><head>
    <SCRIPT>
    function clickTo()
    {
    document.links[0].href=document.location.search.substring(1);
    document.links[0].click();
    }
    </SCRIPT>
    </head>
    <body onload="clickTo();">
    <script>
    if (navigator.appName.indexOf("Microsoft") < 0) location.replace(location.search.substring(1));
    </script>
    <form>
    <a href="Location.html"><input type=hidden onclick="clickTo();"></a>
    </form>
    </body></html>


  •  

    Tags for this Thread

    Posting Permissions

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