1. 程式人生 > >獲取地址欄參數(E積分項目)

獲取地址欄參數(E積分項目)

on() function sea 獲取參數 att highlight doc ati ems

//地址欄獲取參數
function getQueryString(name) {
  var search = document.location.hash;
  var pattern = new RegExp("[?&]" + name + "\=([^&]+)", "g");
  var matcher = pattern.exec(search);
  var items = null;
  if (null != matcher) {
    try {
      items = decodeURIComponent(decodeURIComponent(matcher[1]));
    } catch (e) {
      try {
        items = decodeURIComponent(matcher[1]);
      } catch (e) {
        items = matcher[1];
      }
    }
  }
  return items;
}

傳的時候:

$(function() {
    $(".Jump").click(function(){
			window.location.href=‘http://10.133.254.129:9000/#/card-search-result?result=123456‘
		});
	})

  

取的時候 let result = getQueryString(‘result‘);

獲取地址欄參數(E積分項目)