Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I know, I know..it's not always accurate, but I have a problem.

I have a script that I link to from my pages (a refer a friend script). At first I used a normal html link to the script and the HTTP_REFERER worked. I need it to work because it depends on the page they are on that gets advertised. If they were on cats.html and pressed the link, it would use the www.page.com/cats.html in the email. This works PERFECTLY, it works.

The problem lies when I make a new custom javascript window from the link.

<A HREF="javascript:window.open('raf.pl', '','toolbar=no width=400 height=500 scrolling=yes'); void('');">
Now, when it loads raf.pl (Refer a Friend), it doesn't record the referer.

Can someone give me any ideas on how to get this to work? I was thinking about using a form with a hidden field, but I don't want to use a form button. Is there a way to make a form link instead and have it open in a presized window?

This isn't a strictly JS question or an HTML question, but a combination of those and perl, so don't downvote or delete this post. I really need help on this.

Replies are listed 'Best First'.
Re: http referer
by etcshadow (Priest) on Feb 04, 2004 at 03:14 UTC
    Instead of <a href="javascript:window.open(raf.pl')...">, try doing: <a href="raf.pl" target=_blank>, which will still open a new window (that's what the target=_blank means).
    ------------ :Wq Not an editor command: Wq
      The problem with that is, I need to presize the window to 400x500.
        Why on earth are you doing that, I, and most people, hate it when javascript takes control away from my surfing.

        (Not that it would actually work since I turned that stuff off, but still)
Re: http referer
by Cody Pendant (Prior) on Feb 04, 2004 at 04:33 UTC

    As users have to have JavaScript in order to use your "email to a friend" I think you should use JavaScript to figure out the location as well.

    if you get the

    document.location.href
    using javascript before, that will work.
    myReferrer = document.location.href; myScriptAndReferrer = 'raf.pl?' + myReferrer; // and then later document.write your link document.write('<A HREF="javascript:window.open(' + myScriptAndReferre +r
    etc etc

    But seriously. What happens to users without JavaScript?



    ($_='kkvvttuubbooppuuiiffssqqffssmmiibbddllffss')
    =~y~b-v~a-z~s; print
      Thanks, I think that will work great..a bit less editing than the url_param method. I had the idea but I don't know if it's possible or just stupid, but thought I would toss it out there.

      Is it possible to call a script using SSI that all it does it gather what page loaded it? Then somehow pass that information to my form without using JS? For example, the SSI tells you that the page it's on is www.mypage.com/test.html and somehow pass that as a hidden field inside the form?

    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: http referer
by The Mad Hatter (Priest) on Feb 04, 2004 at 03:08 UTC
    Make raf.pl look for a form variable ref (or similar), or if that doesn't exist, in HTTP_REFERER. Then in the JS link do this: <A HREF="javascript:window.open('raf.pl?ref=URL',...); void('');">
      I had that idea already, if nothing else works I'll have to be forced to use url_params. The only reason I didn't go with that already is because I was hoping there would be an easier way where I wouldn't have to edit the code for each page. I'd kind of like for the HTTP_REFERER to be passed automatically if possible, but it doesn't look like it will be.

      Thanks for the suggestion.

Re: http referer
by Anonymous Monk on Feb 04, 2004 at 03:06 UTC
    No it's not just JS or HTML! The problem is I need to pass the refering url into my PERL script, so this IS a perl problem.