Template:JS/ParseUrlQueryString

From 2014.igem.org

Revision as of 21:16, 12 November 2014 by Kdrinkwa (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


This template provides JavaScript functions getQueryString() and parseQueryString(qs).

getQueryString() grabs the entire query string (everything after the "?") from the current page URL, and returns it unmodified.

parseQueryString(qs) accepts a query string as input, and parses the parameters into an Object like this: {"color": "blue", "number": "3", "units": "centimeters"}. Note that everything in the returned Object will be a String, so if you want to get data of a different type, you will have to use conversion methods such as parseInt().