为了避免这样的窘境,你需要稍稍研究一下(解决方法),而最好的起点就是万维网协会(World Wide Web Consortium)所发布的HTML 4.0规范的第18章。这一规范的这一部分描述了脚本编写的要求,并列出了HTML文档里一些内置可用的基础事件。这些事件都显示在表格A里,它们都是最基本的事件。表格B描述了微软的Internet Explorer以及Mozilla所支持的额外事件。在一个受到控制的环境里,例如在浏览器及其版本可以自由指定的内部网(Intranet)里,额外的事件处理器就都可以使用了,因此很多的事情都可以实现。
表格A | ||
事件名称 | 处理器 | 描述 |
blur | onblur | Element loses focus |
change | onchange | Element's value has changed due to user action |
click | onclick | Element clicked |
dblclick | ondblclick | Element double clicked |
focus | onfocus | Element receives focus |
keydown | onkeydown | Keyboard key pressed |
keypress | onkeypress | Combination of keydown and keyup, used for keyboard combinations |
keyup | onkeyup | Keyboard key released |
load | onload | Window or frame has loaded |
mousedown | onmousedown | Mouse button is pressed over an element |
mousemove | onmousemove | Mouse pointer is moved while over an element |
mouseout | onmouseout | Mouse pointer is moved off an element |
mouseover | onmouseover | Mouse pointer is over an element |
mouseup | onmouseup | Mouse button is released over an element |
reset | onreset | Form is reset |
select | onselect | Text in text field is selected |
submit | onsubmit | Form is submitted |
unload | onunload | Window or frame has unloaded |
HTML所支持的一些内置的基本事件
表格B | ||
事件名称 | 处理器 | 描述 |
abort | onabort | User aborted image download |
blur | onblur | Element loses focus |
change | onchange | Element's value has changed due to user action |
click | onclick | Element clicked |
contextmenu | oncontextmenu | User right clicks on document creating context menu |
dblclick | ondblclick | Element double clicked |
dragenter | ondragenter | Object dragged to target element |
dragover | ondragover | Object dragged over target element |
error | onerror | Error occurs during object loading |
focus | onfocus | Element receives focus |
keydown | onkeydown | Keyboard key pressed |
keypress | onkeypress | Combination of keydown and keyup, used for keyboard combinations |
keyup | onkeyup | Keyboard key released |
load | onload | Window or frame has loaded |
mousedown | onmousedown | Mouse button is pressed over an element |
mousemove | onmousemove | Mouse pointer is moved while over an element |
mouseout | onmouseout | Mouse pointer is moved off an element |
mouseover | onmouseover | Mouse pointer is over an element |
mouseup | onmouseup | Mouse button is released over an element |
reset | onreset | Form is reset |
resize | onresize | Object is being resized |
scroll | onscroll | User moves an object's scroll bar |
select | onselect | Text in text field is selected |
submit | onsubmit | Form is submitted |
unload | onunload | Window or frame has unloaded |
额外的浏览器事件