当前位置: 首页 > 网络学院 > 客户端脚本教程 > JavaScript > JS事件参考
Events are normally used in combination with functions, and the function will not be executed before the event occurs!
事件一般和函数是混合使用的,在事件发生以前一般函数是不会执行的!
New to HTML 4.0 was the ability to let HTML events trigger actions in the browser, like starting a JavaScript when a user clicks on an HTML element. Below is a list of the attributes that can be inserted into HTML tags to define event actions.
HTML4.0的新属性就是可以在浏览器中激发HTML事件。当用户点击一个一个HTML元素时,可以激发JS。下面的列表列举了可以插入HTML标签中来定义事件动作的属性。
FF: Firefox, N: Netscape, IE: Internet Explorer
FF:火狐,N:网景,IE
Attribute 属性 | The event occurs when... 事件发生时机 | FF | N | IE |
---|---|---|---|---|
onabort | Loading of an image is interrupted 图片下载被打断时 | 1 | 3 | 4 |
onblur | An element loses focus 元素失去焦点时 | 1 | 2 | 3 |
onchange | The content of a field changes 框内容改变时 | 1 | 2 | 3 |
onclick | Mouse clicks an object 鼠标点击一个对象时 | 1 | 2 | 3 |
ondblclick | Mouse double-clicks an object 鼠标双击一个对象时 | 1 | 4 | 4 |
onerror | An error occurs when loading a document or an image 当加载文档或图片时发生错误时 | 1 | 3 | 4 |
onfocus | An element gets focus 当元素获取焦点时 | 1 | 2 | 3 |
onkeydown | A keyboard key is pressed 按下键盘按键时 | 1 | 4 | 3 |
onkeypress | A keyboard key is pressed or held down 按下或按住键盘按键时 | 1 | 4 | 3 |
onkeyup | A keyboard key is released 放开键盘按键时 | 1 | 4 | 3 |
onload | A page or an image is finished loading 页面或图片加载完成时 | 1 | 2 | 3 |
onmousedown | A mouse button is pressed 鼠标被按下时 | 1 | 4 | 4 |
onmousemove | The mouse is moved 鼠标被移动时 | 1 | 6 | 3 |
onmouseout | The mouse is moved off an element 鼠标离开元素时 | 1 | 4 | 4 |
onmouseover | The mouse is moved over an element 鼠标经过元素时 | 1 | 2 | 3 |
onmouseup | A mouse button is released 释放鼠标按键时 | 1 | 4 | 4 |
onreset | The reset button is clicked 重新点击鼠标按键时 | 1 | 3 | 4 |
onresize | A window or frame is resized 当窗口或框架被重新定义尺寸时 | 1 | 4 | 4 |
onselect | Text is selected 文本被选择时 | 1 | 2 | 3 |
onsubmit | The submit button is clicked 点击提交按钮时 | 1 | 2 | 3 |
onunload | The user exits the page 用户离开页面时 | 1 | 2 | 3 |