Get Query String Variable Value in JavaScript

  1. function getParameterByName(name)  
  2. {  
  3.     name = name.replace(/[\[]/, "\\\[")  
  4.         .replace(/[\]]/, "\\\]");  
  5.     var regexS = "[\\?&]" + name + "=([^&#]*)",  
  6.         regex = new RegExp(regexS),  
  7.         results = regex.exec(window.location.href);  
  8.     if(results == null)  
  9.     {  
  10.         return "";  
  11.     }  
  12.     else  
  13.     {  
  14.         return decodeURIComponent(results[1].replace(/\+/g, " "));  
  15.     }  
  16. }  

 

Using in JavaScript

  1. var param = getParameterByName('<param_name>') ;