js 获取URL中参数小函数
描述:获取url中所有参数,返回一个以参数名为下标,参数值为值的数组对象。例:[key-value, key-value,...]
getUrlParam = function () {
var vars = [];
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split("&");
for (var i = 0; i < hashes.length; i++) {
hash = hashes[i].split("=");
vars[hash[0]] = hash[1];
}
return vars;
}