Home  >  Article  >  Web Front-end  >  location.search在客户端获取Url参数的方法_javascript技巧

location.search在客户端获取Url参数的方法_javascript技巧

WBOY
WBOYOriginal
2016-05-16 18:25:28982browse
复制代码 代码如下:

var id;
function getid()
{
var url=location.search;
var Request = new Object();
if(url.indexOf("?")!=-1)
{
var str = url.substr(1) //去掉?号
strs = str.split("&");
for(var i=0;i{
Request[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);
}
}
id=Request["id"];
document.getElementById('td_fa').innerHTML=id + "页面信息";
}

这样就好办了。。。传参和.net一样"http://www.aaa.html?id=1"就可以了。
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn