您的位置:首页 > Web前端 > JavaScript

js获取页面get传递的参数

2016-12-20 21:45 197 查看
function getparastr(strname) {
var hrefstr, pos, parastr, para, tempstr;
hrefstr = window.location.href;
pos = hrefstr.indexOf("?")
parastr = hrefstr.substring(pos + 1);
para = parastr.split("&");
tempstr = "";
for (i = 0; i < para.length; i++) {
tempstr = para[i];
pos = tempstr.indexOf("=");
if (tempstr.substring(0, pos) == strname) {
return tempstr.substring(pos + 1);
}
}
return null;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐