方法一

function GetUrlParam (name) { 
     return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.href) || [, ""])[1].replace(/\+/g, '%20')) || null 
}

  

方法二

function getUrlParam(paramName) {
      const url = document.location.toString()
      const arrObj = url.split("?")
      if(arrObj.length > 1) {
        const arrPara = arrObj[1].split("&");
        for (var i = 0; i < arrPara.length; i++) {
          const arr = arrPara[i].split("=");
          if (arr != null && arr[0] == paramName) {
            return arr[1];
          }
        }
        return ""
      }
      else {
        return ""
      }
}

  

相关文章:

  • 2021-09-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-08
  • 2021-07-24
猜你喜欢
  • 2021-09-22
  • 2021-12-03
  • 2022-02-20
  • 2022-12-23
  • 2021-08-01
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案