Template:JS/ParseUrlQueryString
From 2014.igem.org
(Difference between revisions)
Kdrinkwa (Talk | contribs)
(Created page with "<html> <script type="text/javascript"> function getQueryString() { var wholeURL = document.location.href; var index = wholeURL.indexOf("?"); if (index == -1) { return '';...")
(Created page with "<html> <script type="text/javascript"> function getQueryString() { var wholeURL = document.location.href; var index = wholeURL.indexOf("?"); if (index == -1) { return '';...")
Latest revision as of 21:16, 12 November 2014
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().