获取URL的参数
需要编辑自定义函数
function getUrlParam(key){var url = decodeURI(window.location.href);var paramMap = {};var paramStr = url.split("?")[2];if (paramStr && paramStr != "") {var paramStrArr = paramStr.split("&");for (var i = 0; i < paramStrArr.length; i++) {var temp = paramStrArr[i];var indexE = temp.indexOf("=");var pKey = temp.substring(0, indexE);var pVal = temp.substring(indexE + 1);paramMap[pKey] = pVal;}}return paramMap[key];
}
引用例子
例如URL地址:
.../spa/workflow/static4form/index.html?_rdm=166666666666666#/main/workflow/req?iscreate=1&workflowid=122222&cs1=1&cs2=2
若需要获取cs1参数与cs2参数
则流程表单中,点击插入代码块
在中间添加上边的自定义函数,以及引用自定义函数,读取相关参数
例子
<script>
var cs1 = getUrlParam("cs1"); //获取URL中的cs1参数
var cs2 = getUrlParam("cs2"); //获取URL中的cs2参数function getUrlParam(key){var url = decodeURI(window.location.href);var paramMap = {};var paramStr = url.split("?")[2];if (paramStr && paramStr != "") {var paramStrArr = paramStr.split("&");for (var i = 0; i < paramStrArr.length; i++) {var temp = paramStrArr[i];var indexE = temp.indexOf("=");var pKey = temp.substring(0, indexE);var pVal = temp.substring(indexE + 1);paramMap[pKey] = pVal;}}return paramMap[key];
}</script>
``