Home  >  Article  >  Web Front-end  >  JS intercepts the value information of the parameter after the question mark in the url_javascript skills

JS intercepts the value information of the parameter after the question mark in the url_javascript skills

WBOY
WBOYOriginal
2016-05-16 16:50:411942browse

Copy code The code is as follows:

var url=location.search;
var ename ;
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]]=(strs[ i].split("=")[1]);
}
}
ename = Request["ename"];

For example: url is: http: //www.medivh.com?ename=right

Then the obtained ename is: right.
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