Snippet Fire

Beta
 Log In    |   Sign Up

Javascript : Get QueryString Values Using Javascript

Added on Jan-20-2012 by mjudin
For Javascript

Tags : querystring

This function outputs the name and value of each item in a querystring.

DOWNLOAD

function getParameterByName(name)
{
  name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
  var regexS = "[\\?&]" + name + "=([^&#]*)";
  var regex = new RegExp(regexS);
  var results = regex.exec(window.location.href);
  if(results == null)
    return "";
  else
    return decodeURIComponent(results[1].replace(/\+/g, " "));
}


    

Report Snippet

blog comments powered by Disqus