Skip to content

Instantly share code, notes, and snippets.

@jation
Last active July 30, 2016 11:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jation/31bb5c42403ac781dcdd to your computer and use it in GitHub Desktop.
Save jation/31bb5c42403ac781dcdd to your computer and use it in GitHub Desktop.
取URL参数
/*
location.search == '?a=1&b=&c
return {a:'1',b:''}
//注意是字符串……
*/
function getUrlParams() {
var qs = location.search.split("+").join(" ");
var params = {}, tokens, re = /[?&]?([^=]+)=([^&]*)/g;
while (tokens = re.exec(qs)) params[decodeURIComponent(tokens[1])] = decodeURIComponent(tokens[2]);
return params;
}
@swenhu
Copy link

swenhu commented Jul 30, 2016

Orz 好厉害!!!!!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment