Created
July 7, 2018 10:35
-
-
Save flxxyz/b218946a0aff2d5ad46cd902c82e8698 to your computer and use it in GitHub Desktop.
javascript自用简易获取url参数
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
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