js - 下拉刷新后, 保留当前页面的request参数 merge_parameter_and_refresh 非常好用的函数,

访问量: 83

参考>>>....

function merge_parameter_and_refresh(key, value) {
  key = escape(key); value = escape(value);
  var kvp = document.location.search.substr(1).split('&');
  if (kvp == '') {
    document.location.search = '?' + key + '=' + value;
  }
  else {
    var i = kvp.length; var x; while (i--) {
      x = kvp[i].split('=');
      if (x[0] == key) {
        x[1] = value;
        kvp[i] = x.join('=');
        break;
      }
    }
    if (i < 0) { kvp[kvp.length] = [key, value].join('='); }
    //this will reload the page, it's likely better to store this until finished
    document.location.search = kvp.join('&');
  }
}

订阅/RSS Feed

Subscribe

分类/category