javascript and querystrings

Discussion in 'JavaScript' started by relixx, Aug 10, 2005.

  1. #1
    Is it possible to access querystring variables with javascript like you can with ASP/PHP/etc?
     
    relixx, Aug 10, 2005 IP
  2. anotherchancetosee

    anotherchancetosee Guest

    Messages:
    53
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Absolutely, you just need to do a bit of Javascript text parsing to pluck them from the URL. I use something like it to pass latitutde and longitude to my Google Maps code for http://racingcircuits.blogspot.com
     
    anotherchancetosee, Aug 10, 2005 IP
  3. J.D.

    J.D. Peon

    Messages:
    1,198
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Use document.location.search to get the search argument string and then parse it (i.e. look for the & and = characters) to break it onto individual arguments.

    J.D.
     
    J.D., Aug 10, 2005 IP
    relixx likes this.