Last active
October 29, 2017 08:35
-
-
Save CatzillaOrz/3d261b831e1e87b085bb804586f3db7f to your computer and use it in GitHub Desktop.
获取Url-Params
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
//simple define fn | |
//根据param name获取url中params的值 | |
function getUrlParam(name) { | |
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); | |
var r = window.location.search.substr(1).match(reg); | |
if (r != null) { | |
return unescape(r[2]); | |
} | |
return null; | |
} | |
//use it | |
var docId = getUrlParam('docid'); | |
var env = getUrlParam('env'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment