定义方法:
function getParam(paramName) { paramValue = ""; isFound = false; paramName = paramName.toLowerCase(); var arrSource = this.location.search.substring(1, this.location.search.length).split("&"); if (this.location.search.indexOf("?") == 0 && this.location.search.indexOf("=") > 1) { if (paramName == "returnurl") { var retIndex = this.location.search.toLowerCase().indexOf('returnurl='); if (retIndex > -1) { var returnUrl = decodeURIComponent(this.location.search.substring(retIndex + 10, this.location.search.length)); if ((returnUrl.indexOf("http") != 0) && returnUrl != "" && returnUrl.indexOf(location.host.toLowerCase()) == 0) returnUrl = document.location.protocol + "//" + returnUrl; return returnUrl; } } i = 0; while (i < arrSource.length && !isFound) { if (arrSource[i].indexOf("=") > 0) { if (arrSource[i].split("=")[0].toLowerCase() == paramName.toLowerCase()) { paramValue = arrSource[i].toLowerCase().split(paramName + "=")[1]; paramValue = arrSource[i].substr(paramName.length + 1, paramValue.length); isFound = true; } } i++; } } return paramValue; }
使用:getParam('id')