gistfile1.txt getParameterByName = function (a,url) { a = a.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); var c = new RegExp("[\\?]" + a + "=([^#]*)"), b = c.exec(location.search); if(url){ b = c.exec(url); } return b == null ? "" : decode
getParameterByName = function (a,url) { a = a.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); var c = new RegExp("[\\?&]" + a + "=([^&#]*)"), b = c.exec(location.search); if(url){ b = c.exec(url); } return b == null ? "" : decodeURIComponent(b[1].replace(/\+/g, " ")) } 两个参数,一个是你需要截取的字段,一个是get请求网址 getParameterByName("fr","https://baike.baidu.com/item/jpgraph/5253147?fr=aladdin")//aladdin