js函数,解析页面跳转携带的参数
function parseParams(param) { param = param.substr(1, param.length - 1); var paramArray = new Array(); var pArray = param.split('&'); for (var i = 0; i < pArray.length; i++) { var attributeArray = pArray[i].split('='); if ('backUrl' == attributeArray[0]) { paramArray[attributeArray[0]] = pArray[i].substr(pArray[i].indexOf('=') + 1, pArray[i].length); } else { paramArray[attributeArray[0]] = attributeArray[1]; } } return paramArray; };
页面携带参数跳转案例:
function openDetail(entCity) { $.ligerDialog.open({ content: '<div id="wrapDiv"></div>', title: '检测详情', url: JWPT.projectName + 'baseinfo/agrisample/agriSampleListForCount.jsp?entCity=' + entCity, height: 600, 800, isHidden: true, modal: true, isResize: true }); }
js函数应用
var param = window.location.search; var paramArray = parseParams(param); var entCity = decodeURI(paramArray.entCity); //decodeURI函数解决传递中文参数乱码问题