【发布时间】:2012-07-10 12:25:52
【问题描述】:
对于内联事件监听器,我指的是用于事件注册的 HTML 元素属性,例如 onsubmit/onreset 属性,而不是用于注册事件的 dom 节点属性。
我之所以问,是因为当我注册一个事件处理程序时,该处理程序返回 false 到表单的 onsubmit/onreset 属性,通过提交/重置执行提交/重置过程。
<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>
【问题讨论】:
-
你能举个例子说明你的问题吗,因为你的问题很不清楚。
-
是的,使用
onsubmit="return f();"。
标签: javascript