Skip to content

Instantly share code, notes, and snippets.

@Natumsol
Created December 20, 2017 05:50
Show Gist options
  • Select an option

  • Save Natumsol/329bcd6d9583e8035e4c4d5e7f46a5dc to your computer and use it in GitHub Desktop.

Select an option

Save Natumsol/329bcd6d9583e8035e4c4d5e7f46a5dc to your computer and use it in GitHub Desktop.
获取url 查询参数
function getParams(url) {
var result = {};
url = decodeURI(url);
if (typeof url == "string" && url.indexOf("?") != -1) {
var params = url.match(/\?.*/)[0].trim().replace(/^\?/, "").split("&");
for (var i = 0; i < params.length; i++) {
var temp = params[i].split("=");
result[temp[0]] = temp[1];
}
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment