Here are two examples written in JavaScript, how to get a parameter from the current url:

1. using regular expressions is here

2. using string functions is here

I prefer the first solution. Here’s the script:

function gup( 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 results[1];
}

Advertisements