当前位置: 首页 > 网络学院 > 网页制作基础教程 > XHTML > XHTML 事件
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 attributes that can be inserted into HTML tags to define event actions.
HTML4.0的新特征让其能在浏览器中使用HTML事件触发,像用户点击HTML元素时就能开始一个JavaScript。下面是一列可以插入HTML标签中的属性来定义事件行为。
If you want to learn more about programming with these events, you should study our JavaScript tutorial .
如果你想学有关这些元素事件的更多程序。你可以学习JavaScript 教程 。
只在body和frameset元素中才有效
Attribute 属性 | Value 值 | Description 描述 |
---|---|---|
onload | script | Script to be run when a document loads 装载时 |
onunload | script | Script to be run when a document unloads 卸载时 |
Only valid in form elements.
在表单元素中才有效。
Attribute 属性 | Value 值 | Description 描述 |
---|---|---|
onchange | script | Script to be run when the element changes 当元素有改变时脚本会执行 |
onsubmit | script | Script to be run when the form is submitted 当表单提交时... |
onreset | script | Script to be run when the form is reset 当表单重置时... |
onselect | script | Script to be run when the element is selected 元素被选中时... |
onblur | script | Script to be run when the element loses focus 元素失去焦点时... |
onfocus | script | Script to be run when the element gets focus 元素得到焦点时... |
Not valid in base, bdo, br, frame, frameset, head, html, iframe, meta, param, script, style, and title elements.
在 base, bdo, br, frame, frameset, head, html, iframe, meta, param, script, style,和 title 元素里都无效.
Attribute 属性 | Value 值 | Description 描述 |
---|---|---|
onkeydown | script | What to do when key is pressed 当键按下时做什么 |
onkeypress | script | What to do when key is pressed and released 当键按下然后释放时做什么 |
onkeyup | script | What to do when key is released 当键释放时做什么 |
Not valid in base, bdo, br, frame, frameset, head, html, iframe, meta, param, script, style, title elements.
在 base, bdo, br, frame, frameset, head, html, iframe, meta, param, script, style,和 title 元素里都无效.
Attribute 属性 | Value 值 | Description 描述 |
---|---|---|
onclick | script | What to do on a mouse click 单击时... |
ondblclick | script | What to do on a mouse double-click 双击时... |
onmousedown | script | What to do when mouse button is pressed 按下时... |
onmousemove | script | What to do when mouse pointer moves 移动时... |
onmouseout | script | What to do when mouse pointer moves out of an element 鼠标移开元素时 |
onmouseover | script | What to do when mouse pointer moves over an element 鼠标在元素上方时 |
onmouseup | script | What to do when mouse button is released 鼠标释放时 |