JS获取QueryString(Jquery)

姬庆
2023-12-01
QueryString = { 
     data: {}, 
     Initial:  function () { 
         var  aPairs, aTmp; 
         var  queryString =  new  String(window.location.search); 
         queryString = queryString.substr(1, queryString.length);  //remove   "?"    
         aPairs = queryString.split( "&" ); 
         for  ( var  i = 0; i < aPairs.length; i++) { 
             aTmp = aPairs[i].split( "=" ); 
             this .data[aTmp[0]] = aTmp[1]; 
        
     }, 
     GetValue:  function (key) { 
         return  this .data[key]; 
    

 

1
2
//先初始化 
QueryString.Initial();

 

1
2
//例:获得名为deliverQty的参数值 
var  deliverQty = parseInt(QueryString.GetValue( 'deliverQty' )); 

 

转载于:https://www.cnblogs.com/qqhfeng/p/10321928.html

 类似资料: