因为你两次定义了 document.form1.onsubmit(),但实际上执行的时候,只以最后定义的函数为准,也就是说的你嵌套定义没有用,所以最好不要嵌套定义函数。试运行以下代码即知
<script>
function window.onload(){
alert("window is onloading...");
a=confirm("go on?");
if(a){function document.onclick(){ alert("document has been clicked,and you want to go on");}}
else{ function document.onclick(){ alert("document has been clicked,but you stop it");}}
}
</script>
你可以在 document.form1.onsubmit() 函数内部进行判断,即可
<script>
function window.onload(){
alert("window is onloading...");
a=confirm("go on?");
if(a){function document.onclick(){ alert("document has been clicked,and you want to go on");}}
else{ function document.onclick(){ alert("document has been clicked,but you stop it");}}
}
</script>
你可以在 document.form1.onsubmit() 函数内部进行判断,即可
var res;
function document.form1.onsubmit(){
if(confirm(txt)){
res=(evt=="")?true:eval(evt+"()");
return res;
}
else return false;
}