Skip to content

Instantly share code, notes, and snippets.

@ladyrick
Last active April 6, 2017 05:58
Show Gist options
  • Save ladyrick/64b25fe2ec63da7cc0843fbb23afaa46 to your computer and use it in GitHub Desktop.
Save ladyrick/64b25fe2ec63da7cc0843fbb23afaa46 to your computer and use it in GitHub Desktop.
用JS获取地址栏参数的方法
function GetQueryString(name)
{
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if(r!==null) {
return unescape(r[2]);
} else {
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment