Getting values from page 1 to page 2 in javasxcript

i have 2 .aspx (dotnet ) pages

page 1- i have a function to open a new window with the given url. i am paasiing paramaters thr’ this url.

i want to get the values of the parameters in page2
currently i can get the paramters in code behind as request.Querystring("Param1);
but how do i get it in javascript on page2

Hi there,

You can use this function:

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

Say you had a page, where the url is http://localhost/projects/index.html?page=1

You can then do:

console.log(getParameterByName("page"));

which will output “1”

I can’t take credit for this. i found it on StackOverflow: http://stackoverflow.com/questions/901115/how-can-i-get-query-string-values