Regularly get the parameters passed in the address bar

Record a method to quickly obtain the parameters passed by the browser address bar

/** 
 * //Get the parameters passed in the address bar 
          * @param str Parameter name string 
          * @returns {*} 
          * @constructor 
          */ 
function getURLParame(str) { 
   var reg = new RegExp("(^|&)" + str + "=([^&]*)(&|$)"); 
   var r = window.location.search.substr(1).match(reg); 
   if(r != null) return unescape(r [2]); 
   return null; 
}

Guess you like

Origin blog.csdn.net/yunxiang1224/article/details/107064972