Error!
Success!

Simple JavaScript key/value Query String Collection

0
kicks

Simple JavaScript key/value Query String Collection  (Unpublished)

"The property window.location.search will return the query string portion of the URL, including the ‘?’ delimiter. For example, it would return '?q=software&ps=10' in the example URL at piggy.com above (if there’s no query string, search is an zero-length string). The problem with search is that the key/value pairs have to be manually parsed out. A collection-like object accessible in the same manor as a hash table (e.g. var value = collection[key]) is a much more convenient and useful way of representing the query string. In lieu of such an object in window, I’ve created a very simple JavaScript snippet that represents the query string as an object. The object’s properties are the query string keys, and the properties’ values are the key values. Make your life easier and drop this puppy somewhere in your global scope. A closure is used to make it play nice with the neighbors."


Kicked By:
Drop Kicked By: