onclick 的意思就是鼠标点下去的时候触发的js方法
<button type="submit" οnclick="javascript:return onsave();"> 这里return的意义就在于当 执行完onsave 方法如果拿到的是false表单是不能提交的。
onload 和onunload的意思就是页面加载和页面离开的时候触发的方法
function hello(){
alert("欢迎您的光临!") ;
}
function byebye(){
alert("您要走了?下次别来了!") ;
}
<body onLoad="hello()" onUnload="byebye()">
</body>
onsubmit是和Form捆绑使用的就是Form提交到action的之前触发的方法
<script language="javascript">
function validate(f){
var value = f.email.value ;
if(!/^\w+@\w+.\w+$/.test(value)){
alert("EMAIL输入格式不正确!") ;
f.email.focus() ; // 让email获得焦点
f.email.select() ; // 让已有的内容全选
return false ;
}
return true ;
}
</script>
<form action="test.htm" method="post" name="myform" οnsubmit="return validate(this)">//这里边的this指的是当前这个对象就是这个form
EMAIL:<input type="text" name="email">
<input type="submit" value="提交">
</form>