本文介绍了表单的“动作"和“onsubmit":哪个先执行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试调试一个网页,我看到一个表单元素的开头是
I'm trying to debug a webpage and I see a form element whose opening is
<form name="aspnetForm" method="post" action="default.aspx" onsubmit="javascript:return WebForm_OnSubmit();" id="aspnetForm">
只有 Web form
的基础知识,我想知道 action
和 onsubmit
的执行顺序是什么.
Having only a base knowledge of web form
s, I'm wondering what the order of execution is for the action
and onsubmit
.
推荐答案
如果先解决了action
,那么浏览器就会离开页面,JS执行环境就会消失,就会有在 onsubmit
中无处运行 JS,所以它不是.
If action
was resolved first, then the browser would leave the page, the JS execution environment would go away, and there would be nowhere to run the JS in onsubmit
, so it isn't.
事件处理程序在默认操作之前运行.他们可以取消默认操作.
Event handlers run before default actions. They can cancel default actions.
这篇关于表单的“动作"和“onsubmit":哪个先执行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!