Skip to content

Instantly share code, notes, and snippets.

@jerrybendy
Last active September 5, 2016 10:03
Show Gist options
  • Save jerrybendy/e918a4a43b29a3197661bc318ff867c2 to your computer and use it in GitHub Desktop.
Save jerrybendy/e918a4a43b29a3197661bc318ff867c2 to your computer and use it in GitHub Desktop.
获取 URL 参数的简单实现
function getQueryString (name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
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