hooyantsing's Blog

JS获取URL链接中的参数

字数统计: 61阅读时长: 1 min
2019/11/24

JS获取URL链接中的参数

1
2
3
4
5
6
7
8
9
10
11
12
function getQueryVariable(variable)
    {
           var query =  window.location.search.substring(1);
           var vars = query.split("&");
           for (var i=0;i<vars.length;i++) {
                   var pair =  vars[i].split("=");
                   if(pair[0] ==  variable){return pair[1];}
           }
           return(false);
}

getQueryVariable("id");
CATALOG