location传参数接收参数

Posted wuzhaoyu

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了location传参数接收参数相关的知识,希望对你有一定的参考价值。

直接代码

window.location.href="/weChat/identity/companyIdentity?input_B="+input_B+"&input_A="+encodeURI(input_A)+"&input_C="+encodeURI(input_C)+"&input_D="+encodeURI(input_D);
        var url = decodeURI(window.location.href)
        function parseUrl(){
            //var url=location.href;
            var i=url.indexOf(‘?‘);
            if(i==-1)return;
            var querystr=url.substr(i+1);
            var arr1=querystr.split(‘&‘);
            var arr2=new Object();
            for  (i in arr1){
                var ta=arr1[i].split(‘=‘);
                arr2[ta[0]]=ta[1];
            }
            return arr2;
        }
        var v = parseUrl();//解析所有参数
        console.log(v[‘input_A‘]);//就是你要的结果

 

以上是关于location传参数接收参数的主要内容,如果未能解决你的问题,请参考以下文章