1. <td id="kbyxm"><ruby id="kbyxm"></ruby></td>
    2. <acronym id="kbyxm"></acronym>
      <pre id="kbyxm"></pre>
        <track id="kbyxm"><strike id="kbyxm"></strike></track>
          <tr id="kbyxm"></tr>

        1. <table id="kbyxm"></table>
        2. <acronym id="kbyxm"></acronym>

          js獲取URL上的?值

          獲取URL上的值

          推薦方案:正則表達式判斷獲取

          function getUrlValue(name) {
              var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
              var r = window.location.search.substr(1).match(reg); //獲取url中"?"符后的字符串并正則匹配
              var context = "";
              if (r != null)
                  context = decodeURIComponent(r[2]);
              reg = null;
              r = null;
              return context == null || context == "" || context == "undefined" ? "" : context;
          }
          
          如:
          http://localhost:8080/abc.html?name=張三&age=18
          let name = getUrlValue("name");  //name = 張三
          let age = getUrlValue("age");  //age = 18

           

          已有 0 條評論

            歡迎您,新朋友,感謝參與互動!
            2020日本三级黄色电影_三级黄色电影在线观看_亚洲bt色图噜一噜色视频_国产av在线网站
            1. <td id="kbyxm"><ruby id="kbyxm"></ruby></td>
            2. <acronym id="kbyxm"></acronym>
              <pre id="kbyxm"></pre>
                <track id="kbyxm"><strike id="kbyxm"></strike></track>
                  <tr id="kbyxm"></tr>

                1. <table id="kbyxm"></table>
                2. <acronym id="kbyxm"></acronym>