Created
November 21, 2017 06:06
-
-
Save ThaddeusJiang/f282ec8a730747a4ffb8c4683f3da0a9 to your computer and use it in GitHub Desktop.
获取唯一参数,参数可以包含特殊字符和 &
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 getParam(name) { | |
var reg = new RegExp("(^)" + name + '=([\\s\\S]*)($)'); | |
var r = window.location.search.substr(1).match(reg); | |
return r != null ? r[2] : null; | |
} | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment