时间:2021-07-01 10:21:17 帮助过:2人阅读
这篇文章主要介绍了通过window.location.search来获取页面传来的参数,经测试是OK的
function GetQueryString(name) { var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)","i"); var r = window.location.search.substr(1).match(reg); if (r!=null) return (r[2]); return null; } var sname = GetQueryString("name"); if(sname!=null) { var sname_ = decodeURIComponent(sname); alert(sname_); }
测试
abcd.html?name=xyz
应该弹出xyz