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, width: 800, isHidden: true, modal: true, isResize: true }); }
js函数应用
var param = window.location.search; var paramArray = parseParams(param); var entCity = decodeURI(paramArray.entCity); //decodeURI函数解决传递中文参数乱码问题
原文地址:https://www.cnblogs.com/ysgcs/p/8677058.html
时间: 2024-11-08 12:45:32