JS截取url中问号后面参数的值信息
发布时间:2016-12-30 来源:查字典编辑
摘要:复制代码代码如下:varurl=location.search;varename;varRequest=newObject();if(url...
复制代码 代码如下:
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"];
例如:url是:http://www.medivh.com?ename=right
那么获取的ename就为:right.