/** window.location.search获取url地址?以后的值 获取url参数有两种方法,第一种如下,第二种是通过正则 */ //基本版 function getParam() { var url = window.location.search.slice(1); var arrUrl = url.split("&"); var obj = {}; for(var k in arrUrl) { var re = arrUrl[k].split("="); obj[re[0]] = re[1]; } return obj; } //调用: var param = getParam(); var value1=param['参数1']; var value2=param['参数2']; //正则版 function regParam(key) { var url = window.location.search.slice(1); var reg = new RegExp("(^|&)"+key+"=([^&]*)(&|$)"); var result = url.match(reg); if(!result) { return result[2]; }else{ return null; } } //调用 var value3 = regParam("参数3"); var value4 = regParam("参数4");