JavaScript接收页面参数

小小方法用起来方便,简洁.

function Request(name){
var source = location.search;
var reg = new RegExp("(^|\?|&)"+ name +"=([^&]*)(\s|&|$)", "i");
if (reg.test(source))
return RegExp.$2;
return "";}
 
 
function QueryString(item){
     var sValue=location.search.match(new RegExp("[\?\&]"+item+"=([^\&]*)(\&?)","i"))
     return sValue?sValue[1]:sValue
}

function QueryString(item){
     var sValue=location.search.match(new RegExp("[\?\&]"+item+"=([^\&]*)(\&?)","i"))
     return sValue?sValue[1]:sValue
}

 

posted on 2011-03-31 09:45  Jan.David  阅读(911)  评论(0)    收藏  举报

导航