1. 获取全部的参数信息
function(url) { //从给定的地址或者默认的地址栏中获取全部的参数
var vars = {},
hash;
var hashes = null;
if (!url)
url = window.location.search;
hashes = url.slice(url.indexOf('?') + 1).split('&');
for (var i = 0; i < hashes.length; i++) {
hash = hashes[i].split('=');
if (!!hash && hash[0].length > 0)
vars[hash[0]] = hash[1];
}
return vars;
}
2. 获取指定的参数信息
function(name) {//从浏览器的地址栏中获取指定的参数的值
name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
var regex = new RegExp('[\\?&]' + name + '=([^&#]*)');
var results = regex.exec(window.location.search);
return results === null ? '' : results[1].replace(/\+/g, ' ');
}