js 中的window.location.search.match("XX")
2014-04-29 09:19
441 查看
js代码:
//根据QueryString参数名称获取值
function QueryStringByName(name){
//location对象包含当前有关的URL信息,location是window对象的一部分,可用window.location访问
//search是一个可读可写的属性,可设置或返回当前URL的查询部分(问号?之后的部分)
//match()可在字符串内检索指定的值,或找到一个或多个正则表达式的匹配,类似于indexof(),lastIndexof(),但它返回的是指定的值,而不是字符串的位置。
var result=window.location.search.match(new RegExp("[\?\&]" + name + "=([^\&]+)", "i"));
if(result==null || result.length<0)
{
return "";
}
return result[1];//返回值是数组形式。该数组的内容依赖于 regexp 是否具有全局标志 g。
}
//根据QueryString参数名称获取值
function QueryStringByName(name){
//location对象包含当前有关的URL信息,location是window对象的一部分,可用window.location访问
//search是一个可读可写的属性,可设置或返回当前URL的查询部分(问号?之后的部分)
//match()可在字符串内检索指定的值,或找到一个或多个正则表达式的匹配,类似于indexof(),lastIndexof(),但它返回的是指定的值,而不是字符串的位置。
var result=window.location.search.match(new RegExp("[\?\&]" + name + "=([^\&]+)", "i"));
if(result==null || result.length<0)
{
return "";
}
return result[1];//返回值是数组形式。该数组的内容依赖于 regexp 是否具有全局标志 g。
}
相关文章推荐
- 关于js中"window.location.href"、"location.href"
- js 中的window.location.search.match()页面间的传阐述
- window.location.search.substr(一).split(\"&\")代表什么意思
- js 中的window.location.search.match()页面间的传阐述
- 关于js中"window.location.href"、"location.href"、"parent.location.href"、"top.location.href"的用法
- 关于js中"window.location.href"、"location.href"、"parent.location.href"、"top.location.href"的用法
- 关于js iframe 中"window(parent)(top).location.href"的用法
- 关于js中"window.location.href"、"location.href"、"parent.location.href"、"top.location.href"的用法
- 关于js中"window.location.href"、"location.href"、"parent.location.href"、"top.location.href"的用法
- 关于js中"window.location.href"、"location.href"、"parent.location.href"、"top.location.href"的用法
- 关于js中\"window.location.href\"、\"location.href\"、\"parent.location.href\"、\"top.location.href\"的用法
- 关于js中"window.location.href"、"location.href"、"parent.location.href"、"top.location.href"的用法
- 关于js中"window.location.href"、"location.href"重定向
- 关于js中"window.location.href"、"location.href"、"parent.location.href"、"top.location.href"的用法
- 关于js中"window.location.href"、"location.href"、"parent.location.href"、"top.location.href"的用法
- 关于js中"window.location.href"、"location.href"、"parent.location.href"、"top.location.href"的用法
- var djConfig = { isDebug: (window.location.search.indexOf("debug")>-1) };
- 关于js中"window.location.href"、"location.href"、"parent.location.href"、"top.location.href"的用法
- js中window.location.search的用法和作用。
- 6、web(js):js中window.location.search的用法和作用。