首页 > 代码库 > How to get URL parameters with Javascript?

How to get URL parameters with Javascript?

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

So you can use:

myvar = getURLParameter(‘myvar‘);

 

How to get URL parameters with Javascript?