Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

javascript help - passing current url to a cgi link

3stripe3stripe ✭✭
edited November 2005 in Vanilla 1.0 Help
i know this is very simple but i'm stuck... and I need to do this tonight...
(just got an email out of the blue from a client wanting to add text-to-voice links to their website)

the code for this is pretty easy, just a link to their software like this:

http://asp.readspeaker.net/cgi-bin/clientname?customerid=123456&url=http://www.currenturlhere.com

I believe I can find the current url using:

echo $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];

But how do I feed this into the link???

Comments

  • 3stripe3stripe ✭✭
    edited November 2005
    EDIT. Hmmm can I actually use PHP as all the pages are .html files already, maybe there is an even simpler way to do this with javascript.
  • edited November 2005
    window.location in javascript ? document.write("a href=\"http://asp.readspeaker.net/cgi-bin/clientname?customerid=123456&url=" + window.location + "\""); edit: you can't use PHP at all in HTML files.
  • 3stripe3stripe ✭✭
    edited November 2005
    UPDATE. Yes I'm an idiot. I got this working in about 2 minutes. Sorry.
  • Hey thanks grrowl, that's what I just figured out as well. Great minds ha ha :-)
  • I think there is an easier way to do it purely on the server side, if you have the request string.
  • Great minds indeed :) Berga, using HTML you can't do this server-side because HTML files don't get parsed :\ $_SERVER[REQUEST_URI] ?
  • the docu misleads :\
    'REQUEST_URI'

    The URI which was given in order to access this page; for instance, '/index.html'.
  • edited November 2005
    There's probably a way to get the domain name out of there as well; PHP syntax is not my forte. An even better (though not foolproof) method would be to have the page on the receiving end of the link check the referrer.
  • Sigh.... half past midnight and still another hour to go until finished....
  • edited November 2005
    It would be, and i would usually say they should use that, except if the referrer is vital (as in, as vital as a DiscussionID variable here) they don't want to completely neuter people who are using browsers that don't forward the referrer in some circumstances.

    Have faith 3stripe! Hopefully you're getting paid or something, and isn't that what counts now?
  • edited November 2005
    That was the "not foolproof" part. :D
  • Yeah I'm getting paid!
  • 3stripe3stripe ✭✭
    edited November 2005

    Hmmm

This discussion has been closed.