在体内,我有以下内容:
<body onload="loadCheck1();">
这指向以下功能:
function loadCheck1() {
var chkme1 = "<?php echo $_GET['update']; ?>";
if (chkme1 ==1){
window.location = "viewrecipe.php?recipe_name="+recipe_name.value+"&update=2&texty1="+texty1.value+"&texty2="+texty2.value+"&texty3="+texty3.value+"&texty4="+texty4.value+"&texty5="+texty5.value;
}
if (last==3){
window.location = "viewrecipe.php?recipe_name="+recipe_name.value+"&NewFG1="+texty4.value+"&NewAlc="+texty5.value;
}
}
URLviewrecipe.php?update=1
应该加载第一个 window.location 并且viewrecipe.php?update=3
应该加载第二个。
在 Chrome 中,这绝对没问题。在 IE 中,我收到一条错误消息,提示“recipe_name”未定义。
我唯一能想到的是,在 Chrome 中,代码仅在页面实际加载后才会激活。到那时,所有字段值都将被填写。
页面加载后是否有其他方法可以运行功能?