Skip to content

Instantly share code, notes, and snippets.

@flxxyz
Created July 7, 2018 10:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flxxyz/b218946a0aff2d5ad46cd902c82e8698 to your computer and use it in GitHub Desktop.
Save flxxyz/b218946a0aff2d5ad46cd902c82e8698 to your computer and use it in GitHub Desktop.
javascript自用简易获取url参数
var url = {
key: function _get(name, query) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
if (query) {
var r = query.match(reg);
} else {
var r = window.location.search.substr(1).match(reg);
}
if (r != null) {
return unescape(r[2]);
}
return null;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment