javascript获取查询字符串的值
javascript获取查询字符串的值
转自:js中国 http://www.javascriptcn.cn
http://javascriptxml.5d6d.com/thread-5-1-1.html
转自:js中国 http://www.javascriptcn.cn
http://javascriptxml.5d6d.com/thread-5-1-1.html
if (window.location.search == "")
{
alert("页面中未传过值");
}
else
{
var str = window.location.search.substring(1,window.location.search.length);
var arry = str.split("&");
var r;
for (r in arry)
{
//将值对拆开并输出
document.write(arry[r].split("=")[0] + "=" + arry[r].split("=")[1] + "
");
}
}
{
alert("页面中未传过值");
}
else
{
var str = window.location.search.substring(1,window.location.search.length);
var arry = str.split("&");
var r;
for (r in arry)
{
//将值对拆开并输出
document.write(arry[r].split("=")[0] + "=" + arry[r].split("=")[1] + "
");
}
}