Custom Search
Logiclabz
  • Home
  • Javascript
  • Getting Request URL Query String in Javascript using Regex Expression

Getting Request URL Query String in Javascript using Regex Expression

     var url=''
     var objURL = new Object()

     window.location.search.replace(new RegExp( 
"([^?=&]+)(=([^&]*))?", "g" ),function( $0, $1, $2, $3 ){objURL[$1] = $3;})

     for (var strKey in objURL) // loops through each query string
     {
          alert(objURL[strKey]); // alerts value for each query string
     }



Leave a reply


Do you like this post?