表单的“动作”和“onsubmit”:哪个首先执行? [英] A form's "action" and "onsubmit": Which executes first?

查看:117
本文介绍了表单的“动作”和“onsubmit”:哪个首先执行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图调试一个网页,并且看到一个表单元素,它的开头是

 < form name = aspnetFormmethod =postaction =default.aspxonsubmit =javascript:return WebForm_OnSubmit(); ID = aspnetForm > 

仅具有web form s,我想知道动作 onsubmit 的执行顺序。 页面中,JS执行环境将消失,并且无法在 onsubmit 中运行JS,因此它不是。



事件处理程序在默认操作之前运行。他们可以取消默认操作。


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">

Having only a base knowledge of web forms, I'm wondering what the order of execution is for the action and onsubmit.

解决方案

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”:哪个首先执行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆