Simple Query String Handling

Download

Download: sm-querystring.js
Version:
Released:

Have you ever needed to have access to a URL's query string parameters? This tiny library parses a query string into an associative array so the individual parameters are easy to access.

When you include sm-querystring.js it automatically creates a window property named params which is an associative array of the current page's query string parameters.

Example

<script type="text/javascript" src="/javascript/sm-querystring.js" charset="ISO-8859-1"></script>
...
<script type="text/javascript">
document.write('a=' + params['a'] + '<br />');
document.write('b=' + params['b'] + '<br />');
document.write('c=' + params['c'] + '<br />');
</script>

Result

Note

Try these links to change the results above:

Function Signatures

ScriptingMagic.QueryString.parse(queryString)
  • queryString: the query string from a URL
returns an associative array containing the parameters contained in the query string