Skip to content

Instantly share code, notes, and snippets.

@CatzillaOrz
Last active October 29, 2017 08:35
Show Gist options
  • Save CatzillaOrz/3d261b831e1e87b085bb804586f3db7f to your computer and use it in GitHub Desktop.
Save CatzillaOrz/3d261b831e1e87b085bb804586f3db7f to your computer and use it in GitHub Desktop.
获取Url-Params
//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