因为你两次定义了 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() 函数内部进行判断,即可
解决方案 »
- 在产品显示时"新品"标示问题
- 有没有效率好一点的数组对比函数?如内:
- 基于对象的继承
- 为什么firefox对form.submit()没有反应????
- 请教:如何在一个新页面里的OnClick事件中去刷新另一个页面!
- 请教关于自动刷新的问题!!
- select名称为数组,怎么办?
- 一个简单问题!!==>>页面b打开页面a,a关闭时返回值到b中的文本框里,这样写对吗?<A HREF='#' onClick="javascript:self.opener.form[0
- 紧急求救!如何用实现隐藏当前窗口的菜单、地址栏和按钮栏?(在线等待!)
- 新手上路,求大佬指点
- 关于JavaScript的问题
- 问一个超级变态的问题?
var res;
function document.form1.onsubmit(){
if(confirm(txt)){
res=(evt=="")?true:eval(evt+"()");
return res;
}
else return false;
}