Last active
July 30, 2016 11:30
-
-
Save jation/31bb5c42403ac781dcdd to your computer and use it in GitHub Desktop.
取URL参数
This file contains 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
/* | |
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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Orz 好厉害!!!!!!!