function getQueryStringArgs() {
//取得查询字符串并去掉开头的问号
var qs = (location.search.length > 0 ? location.search.substring(1) : "");
//保存数据的对象
args = {};
//取得每一项
items = qs.length ? qs.split("&") : [];
item = null;
name = null;
value = null;
//在for循环中使用
i = 0;
len = items.length;
//逐个将每一项添加到args对象中
for (i = 0; i < len; I++) {
item = items[i].split("=");
name = decodeURLComponent(item[0]);
value = decodeURLComponent(item[1]);
if (name.length) {
args[name] = value;
}
}
return args;
}
//假设查询字符串是?q = javascript & num = 10
var args = getQueryStringArgs();
alert(args["q"]); // “”javascript
alert(args["num"]); //“10”
本文地址:https://blog.csdn.net/only__Y/article/details/107478775
如对本文有疑问, 点击进行留言回复!!
offset、client、scroll (width,height、left,top、X,Y)
网友评论