//獲取URL function getParams(param,val) { var params = window.location.search; var paramStr = "?"; if(params.indexOf("?") == 0 && params.indexOf("=") > 1){ params = params.substring(1, params.length); if(params.indexOf("&") > 1){ var paramsArr = params.split("&"); var isHave = false; for(var i in paramsArr) { var tempArr = paramsArr[i].split("="); if(tempArr[0].toLowerCase() == param.toLowerCase()){ isHave = true; tempArr[1] = val; paramsArr[i] = tempArr.join("="); } } if(!isHave){ paramsArr.push(param + "=" + val); } paramStr += paramsArr.join("&"); }else{ tempArr = params.split("="); if(tempArr[0].toLowerCase() == param.toLowerCase()){ tempArr[1] = val; paramStr += tempArr.join("="); }else{ paramStr += params +"&" + param + "=" + val; } } }else{ paramStr += param + "=" + val; } return paramStr; }