function getNum(url,temp){ var aa try{ aa = url.split('?') }catch(e){ return null } var kksk = aa.shift() var last = url.slice(kksk.length+1,url.length) var a = last.split('&') console.log(a) var b = {} for(let i = 0; i < a.length;i++){ var c = a[i].split('=') b[c[0]]=c[1] } console.log(b['a']) if(b[temp] === undefined){ return null }else{ return b[temp] } //console.log(b[temp]) } getNum('https://www.qq.com?a=b','a')