Created
March 29, 2016 07:30
-
-
Save hcl1687/7d927e9afdf6ff59b54a to your computer and use it in GitHub Desktop.
getAllUrlParams
获取所有的URL参数
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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