Home > Web Front-end > JS Tutorial > Location.search method to obtain Url parameters on the client_javascript skills

Location.search method to obtain Url parameters on the client_javascript skills

WBOY
Release: 2016-05-16 18:25:28
Original
1090 people have browsed it
Copy code The code is as follows:

var id;
function getid()
{
var url=location.search;
var Request = new Object();
if(url.indexOf("?")!=-1)
{
var str = url. substr(1) //Remove the ? number
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 "Page information";
}

This is easy to handle. . . Just pass the parameter "http://www.aaa.html?id=1" as in .net.
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template