Javascript onsubmit()的格式是什么?

Javascript onsubmit()的格式是什么?,javascript,javascript-events,Javascript,Javascript Events,有人能给我解释一下这个函数吗。你在做什么!表单.onsubmit()和表单.onsubmit()!=假是什么意思 //<![CDATA[ var theForm = document.forms['Form']; if (!theForm) { theForm = document.Form; } function __doPostBack(eventTarget, eventArgument) { if (!theForm.onsubmit || (theForm.ons

有人能给我解释一下这个函数吗。你在做什么!表单.onsubmit()和
表单.onsubmit()!=假
是什么意思

//<![CDATA[
var theForm = document.forms['Form'];
if (!theForm) {
    theForm = document.Form;
}
function __doPostBack(eventTarget, eventArgument) {
    if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
        theForm.__EVENTTARGET.value = eventTarget;
        theForm.__EVENTARGUMENT.value = eventArgument;
        theForm.submit();
    }
}
//]]>
表单的含义是什么。在submit
中,它怎么可能是
null
!null
是否为真

当我检查表单.onsubmit()时false我得到:

theForm.onsubmit()
TypeError: object is not a function
theForm.onsubmit() != false
TypeError: object is not a function

表单onsubmit
表单onsubmit()
之间的区别是什么?

表单onsubmit是
提交
事件的事件处理程序。如果为
null
,则未设置任何处理程序。设置时,它应该是一个函数
form.onsubmit()
调用该函数,就像其他函数一样

您在表单.onsubmit()中遇到了这个错误,因为显然没有设置任何处理程序。您需要一起执行整个表达式


如果没有处理程序,或者调用处理程序返回false,则执行代码块

theForm.onsubmit()
TypeError: object is not a function
theForm.onsubmit() != false
TypeError: object is not a function
if (!theForm.onsubmit || (theForm.onsubmit() != false))