获取url参数

function GetQueryString(name)
{
     var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
     var r = decodeURI(window.location.search).substr(1).match(reg);
     if(r!=null)return  unescape(r[2]); return null;
}
function getParam(str, deflt) {
  var search = decodeURIComponent(location.href);
  var result = new RegExp('[\\W]' + str + '(?:[=|\\/])([0-9|a-z]*)').exec(search);
  result = result ? result[1] : deflt;
  return result; 
}

欢迎分享本文,转载请保留出处:前端ABC » 获取url参数

赞 (1)
分享到:更多 ()

发表评论 0