标签:
ref: http://stackoverflow.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);
js - get-the-value-from-the-url-parameter(可以在非模态对话框中使用)
标签:
原文地址:http://www.cnblogs.com/listened/p/4470399.html