当前位置:网站首页>JS get link? The following parameter name or value, according to the URL? Judge the parameters after

JS get link? The following parameter name or value, according to the URL? Judge the parameters after

2022-04-23 17:44:00 Youyoujing

	var url = location.search; // obtain url in "?" The string after the sign  , Include ?
	console.log(url);
	
	function GetRequest() {
    
	    var url = location.search; // obtain url in "?" The string after the sign 
	     
	    var theRequest = new Object();
	    if(url.indexOf("?") != -1) {
    
	        var str = url.substr(1);
	        strs = str.split("&");
	        for(var i = 0; i < strs.length; i++) {
    
	            theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
	        }
	    }
	    return theRequest;
	}
	var Request = undefined;
	Request = GetRequest();
	console.log(Request);// Last obtained field name + value 
	 
	const keys= Object.keys(Request);
	console.log(keys);// Array 
	console.log(keys[0]);// Output a

Case study :
Design draft :
 Insert picture description here
according to url The parameter judgment status after is : resolved , Unresolved , All ;

	var url = location.search; // obtain url in "?" The string after the sign  , Include ?
            // console.log(url);
 
     function GetRequest() {
    
         var url = location.search; // obtain url in "?" The string after the sign 
          
         var theRequest = new Object();
         if(url.indexOf("?") != -1) {
    
             var str = url.substr(1);
             strs = str.split("&");
             for(var i = 0; i < strs.length; i++) {
    
                 theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
             }
         }
         return theRequest;
     }
     var Request = undefined;
     Request = GetRequest();
     // console.log(Request);// Last obtained field name + value 
      
     // const keys= Object.keys(Request);
     // console.log(keys);// Array 
     // console.log(keys[0]);// Output a
     
     let status = Request.status;
     if(status == 2){
    
     	$('.tit05 .tit05div .zhuangtai').text(' All ');
     }else if(status == 1){
    
     	$('.tit05 .tit05div .zhuangtai').text(' resolved ');
     }else{
    
     	$('.tit05 .tit05div .zhuangtai').text(' Unresolved ');
     }

Reference article :
js For a link ? The parameter name or value behind :https://www.cnblogs.com/zxcc/p/11454196.html

版权声明
本文为[Youyoujing]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230550532016.html