aspx Tutorial

NET Articles,jQuery demo, with jQuery, online tutorial,Jquery, SilverLight, Javascript,,JSON, MVC,.NET Articles,demo, Web Services,
Advertise Here


Get our toolbar!


Posted by Aamir Hasan   on Thursday, May 17, 2012 Total Views:  


In this post, you will see how to get querystring value from a URL on client side by using javscript.  

Javascript function

    <script type="text/javascript">

        QueryString = function (str) {

            var url ='&');

            for (var i = 0; i < url.length; i++) {

                var Name = url[i].split('=');

                if (Name[0] == str)

                    return Name[1];





    <script type="text/javascript">







In the above URL, I have passed firstName and lastName querystring values.

Above you will notice that I have called querystring function twice and passed variable name to get value of querystring from URL.


Note: Function will return undefined if when there is no querystring is passed in the URL.


Above function has been tested on following browsers (IE, firefox, chrome, safari, ipad, iphone and opera)


view demo

Protected by Copyscape Online Plagiarism Tool

Add comment

  Country flag

  • Comment
  • Preview

Advertizement 1
Advertizement 2
Advertizement 3
Advertizement 4
Advertizement 5