Simple JavaScript key/value Query String Collection(seattlesoftware.wordpress.com)

submitted by deverdever(350) 4 years, 4 months ago

"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."

add a comment |category: |Views: 249

tags: another

new Add a live kick counter to your blog >> liveImage

You can even customize the image by choosing your own colors, and then clicking the button below to update the preview and the html code:

  • "Kick It" text
  • "Kick It" background
  • kick count text
  • kick count background
  • border

Simply copy and paste this HTML into your blog post.


Users who kicked this story:
Comments:

No comments so far

information Login or create an account to comment on this story