Created
December 20, 2017 05:50
-
-
Save Natumsol/329bcd6d9583e8035e4c4d5e7f46a5dc to your computer and use it in GitHub Desktop.
获取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 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