看看这个:
if(session.getAttribute("mode")!=null){
mode = (String)session.getAttribute("mode");
}
mode
的第一次值是空的,所以我将 mode
值设置为脚本变量,如下所示:
var mode='<%=mode%>';
下面是我调用表单加载的方法,但它说 mode is undefined
bodyOnLoad();
var mode='<%=mode%>';
alert("mode : "+mode);
function bodyOnLoad() {
if(mode.length < 0){
alert("mode empty 111111");
document.getElementById("functiontype").value="view";
document.getElementById("page").value="1";
document.forms["frmTempcard"].submit();
return;
}
}
谁能帮我解决这个问题?
最佳答案
首先声明变量。当您调用函数 bodyOnLoad
时,mode
未定义。
var mode='<%=mode%>';
bodyOnLoad();
关于javascript - 值在 javascript 中未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11880883/