SitePoint Sponsor

User Tag List

Results 1 to 12 of 12
  1. #1
    Level 8 Chinese guy Archbob's Avatar
    Join Date
    Sep 2001
    Location
    Somewhere in this vast universe
    Posts
    3,741
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Can referral scripts pick up javascript links?

    Hi all,
    I was wondering if referral scripts can pick up javascript links like

    Code:
    <A href="#" onclick=window.open(URL)>Link</a>

    I think they can but I've never been sure about it.

  2. #2
    Level 8 Chinese guy Archbob's Avatar
    Join Date
    Sep 2001
    Location
    Somewhere in this vast universe
    Posts
    3,741
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What kind of details?
    I'm mainly talking about PHP referrer method of tracking referrals.

  3. #3
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,044
    Mentioned
    187 Post(s)
    Tagged
    2 Thread(s)

    links

    Sorry, but I don't kow what you mean by "referral scripts". AFAIK, search engine bots, and I imagine most "scrapers" would see the link text and href value, but not the javascript code or what it returns.

  4. #4
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,684
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    Further details will be required before a viable answer can be provided.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  5. #5
    Level 8 Chinese guy Archbob's Avatar
    Join Date
    Sep 2001
    Location
    Somewhere in this vast universe
    Posts
    3,741
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm not talking about search engine bots.
    I'm talking that if a page has a line of code like:
    Code:
    $ref = getenv("HTTP_REFERER");
    Can they Pick it up?

  6. #6
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,044
    Mentioned
    187 Post(s)
    Tagged
    2 Thread(s)

    http referer

    So you mean, if the page "URL" that gets the HTTP_REFERER, is the value that of the page with the window.open link. I haven't tested it, but I don't see why not. I'll try it out and get back unless someone else beats me to it

  7. #7
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,684
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    No.

    When window.open is used, it opens a new window that has no history for getenv() to retrieve. Browsers differ on how to handle this, with some using the parent window location, while others just provide nothing.

    What you can do is use the querystring instead.

    Code Javascript:
    window.open(url+'?referer='+window.location)

    Then use $_GET['referer'] instead of getenv("HTTP_REFERER")
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  8. #8
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,044
    Mentioned
    187 Post(s)
    Tagged
    2 Thread(s)

    script links

    I just threw together some test files
    pass.html
    HTML Code:
    <html><head><title>pass referer?</title>
    </head>
    <body>
    <a href="#" onclick="window.open('referertest.php')">Open Link</a>
    <br>
    <a href="#" onclick="window.location.href='referertest.php'">Go Link</a>
    <br>
    <a href="referertest.php">Reg Link</a>
    </body></html>
    referertest.php
    PHP Code:
    <?php
    echo "referer test <br>";
    $ref getenv("HTTP_REFERER");
    var_dump($ref);
    echo 
    "<br>";
    $sender $_SERVER['HTTP_REFERER'];
    var_dump($sender);
    ?>
    Both javscript links gave bool(FALSE) NULL
    and only the "regular" link showed string(31) "http://localhost/test/pass.html" when testing with IE6.
    All links showed "http://localhost/test/pass.html" with Opera 9.23 and Firefox 2.0.0.11
    These results may have something to do with my preference settings. But of course using HTTP REFERER can't be trusted anyway.

  9. #9
    Level 8 Chinese guy Archbob's Avatar
    Join Date
    Sep 2001
    Location
    Somewhere in this vast universe
    Posts
    3,741
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I guess the answer is no then, oh well, I'll just use regular links.

  10. #10
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,044
    Mentioned
    187 Post(s)
    Tagged
    2 Thread(s)

    referrer

    Ideally, something like what pmw57 suggested would be best. Even with regular links, in Opera I can go to tools -> preferences -> advanced -> network and unclick "enable referrer logging" in which case all links give bool(FALSE) NULL even the regular non-script one. I don't know if Firefox has anything similar, but I imagine there are GreaseMonkey scripts that do. But I guess as long as IE predominates the browsers, regular links would be OK.

  11. #11
    Level 8 Chinese guy Archbob's Avatar
    Join Date
    Sep 2001
    Location
    Somewhere in this vast universe
    Posts
    3,741
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, I'm referring to toplists on other arcade sites, if they don't pick my referral up, it doesn't count as a hit for my site. Its not just me configuring my own settings.

  12. #12
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,044
    Mentioned
    187 Post(s)
    Tagged
    2 Thread(s)

    referrer

    Yes, I figured as much. If they don't ask for a "referer" GET var in the link, then I guess it's out of your control as for doing anything 100&#37; reliable. One can only hope they do something fair. But I think using regular links is your best bet. IE still predominates and I don't think too many users turn off referer tracking. Although I imagine plenty of sites do referer "spoofing" if thats how they tally clicks.


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
  •