2个回答
展开全部
function getQueryString(name) {
var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
var r = window.location.search.substr(1).match(reg);
if (r != null) {
return unescape(r[2]);
}
return null;
}
// 这样调用:
alert(GetQueryString("参数名1"));alert(GetQueryString("参数名2"));
alert(GetQueryString("参数名3"));
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2016-11-21
展开全部
$(function(){
var test= GetArgsFromHref(window.location.href, "n");
});
function GetArgsFromHref(sHref, sArgName) {
var args = sHref.split("?");
var retval = "";
if (args[0] == sHref) {
return retval;
}
var str = args[1];
args = str.split("&");
for (var i = 0; i < args.length; i++) {
str = args[i];
var arg = str.split("=");
if (arg.length <= 1) continue;
if (arg[0] == sArgName) retval = arg[1];
}
return retval;
}
var test= GetArgsFromHref(window.location.href, "n");
});
function GetArgsFromHref(sHref, sArgName) {
var args = sHref.split("?");
var retval = "";
if (args[0] == sHref) {
return retval;
}
var str = args[1];
args = str.split("&");
for (var i = 0; i < args.length; i++) {
str = args[i];
var arg = str.split("=");
if (arg.length <= 1) continue;
if (arg[0] == sArgName) retval = arg[1];
}
return retval;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询