2018-02-20JavaScript几秒 读完 (大约 107 个字)获取url参数获取url参数。 12345678910const getUrlParam = function(param_name) { var reg = new RegExp("(^|&)" + param_name + "=([^&]*)(&|$)"); var r = window.location.search.substr(1).match(reg); if (null != r) return unescape(r[2]); return null;}// url: https://www.baidu.com/s?wd=%E5%AD%97%E6%AE%B5&rsv_spt=1&rsv_iqid=0xd0b8cedf0003ddd6&issp=1&f=8&rsv_bp=1&rsv_idx=2&ie=utf-8&rqlang=cn&tn=baiduhome_pg&rsv_enter=1&rsv_dl=tb&rsv_btype=t&inputT=1124&rsv_t=5d5fy7IgBRPdzAzH14Trm1rHQHMc7tyfekRowuJWwzCd44xNsWtYNcwkvDVBRPAttnsv&rsv_sug3=11&rsv_sug1=7&rsv_sug7=100&oq=get&rsv_pq=f54d93940005c478&rsv_sug2=0&rsv_sug4=5075getUrlParam('wd');// "字段"