ref: http://*.com/questions/979975/how-to-get-the-value-from-the-url-parameter
函数:
function getQueryParams(qs) {
qs = qs.split("+").join(" "); var params = {}, tokens,
re = /[?&]?([^=]+)=([^&]*)/g; while (tokens = re.exec(qs)) {
params[decodeURIComponent(tokens[1])]
= decodeURIComponent(tokens[2]);
} return params;
}
然后可以通过这样方式访问:
//var query = getQueryParams(document.location.search);
//alert(query.foo);