[javascript] How to get URL parameters with Javascript?

Possible Duplicate:
How to get “GET” request parameters in JavaScript?
jQuery querystring
How can I get query string values in JavaScript?

Javascript does not provide a core method to do that, so how to do it?

This question is related to javascript

The answer is


function getURLParameter(name) {
  return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search) || [null, ''])[1].replace(/\+/g, '%20')) || null;
}

So you can use:

myvar = getURLParameter('myvar');