Skip to content

Instantly share code, notes, and snippets.

@hcl1687
Created March 29, 2016 07:30
Show Gist options
  • Save hcl1687/7d927e9afdf6ff59b54a to your computer and use it in GitHub Desktop.
Save hcl1687/7d927e9afdf6ff59b54a to your computer and use it in GitHub Desktop.
getAllUrlParams 获取所有的URL参数
function getAllParams () {
const params = {}
const reg = /([^&?;]*?)=([^&?;]*)/g
while (let match = reg.exec(location.search)) {
if (match[1]) {
const name = decodeURIComponent(match[1])
const value = match[2] ? decodeURIComponent(match[2]) : null
params[name] = value
}
}
return params
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment