Created
November 20, 2017 02:59
-
-
Save ThaddeusJiang/8b435f24b88bc6807d46d8fdf31996ec 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
```js | |
function getUrlParam(name) { | |
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象 | |
var r = window.location.search.substr(1).match(reg); //匹配目标参数 | |
if (r != null) return decodeURI(r[2]); return null; //返回参数值 | |
} | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment