方便获取url中参数的函数
function getQueryStringArgs() {
var qs = (location.search.length > 0 ? location.search.substring(1) : ''),
args = [],
items = qs.length ? qs.split('&') : [],
item = null,
name = null,
value = null,
i = 0,
len = items.length;
for (i=0; i < len; i++) {
item = items[i].split('=');
name = decodeURIComponent(item[0]);
value = decodeURIComponent(item[1]);
if (name.length) {
args[name] = value;
}
}
return args;
}
以数组的形式返回
获取URL指定参数
function getOption(key) {
if (window.location) {
var search = location.search;
if (search == "") {
return "";
}
search = search.slice(1);
var searchArr = search.split("&");
var length_1 = searchArr.length;
for (var i = 0; i < length_1; i++) {
var str = searchArr[i];
var arr = str.split("=");
if (arr[0] == key) {
return arr[1];
}
}
}
return "";
}