对于内联事件侦听器,我指的是用于事件注册的 HTML 元素属性,例如 onsubmit/onreset 属性,而不是用于注册事件的 dom 节点属性。
我之所以问,是因为当我注册一个事件处理程序时,该处理程序向表单的 onsubmit/onreset 属性返回 false,通过提交/重置执行提交/重置过程。
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>New Web Project</title>
<script type="text/javascript">
function f()
{
return false;
}
</script>
</head>
<body>
<form action="" id = "form" onsubmit = "f()" onreset = "f()">
<input type="text">
<input type = "submit" value = "submit">
<input type = "reset" value = "reset">
</form>
</body>
</html>