URL parameters in Javascript

I wanted a piece of code in pure javascript ( no framework required ) that could extract the parameters in the query string part of an URL.

I wanted it to be able to extract the parameters in this format name[key]=value  like they are used in php applications.

I found a piece of code on some other blogs or forum posts but it didn't work as I expected so here is my take on this.

  1. span style="color: #3366CC;">'''&''='

This function one limitation: It doesn't work with multidimensional arrays. It's probably not hard to modify it to work like that but I only needed it to work with single dimension arrays.

1 thought on “URL parameters in Javascript

  1. First, this post looks odd. The avd image brakes the layout.

    Then, as a best practice, you can extract qsParts.length or other array lenghts like this in a variable.
    Also if/else should have {} even with one instruction.

    But these are small things. The method is good!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.