Created
October 29, 2017 08:35
-
-
Save CatzillaOrz/7832d67b6107b2200b39477e49453fcf 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