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 and our DHTML tutorial.
如果你想学有关这些元素事件的更多程序。你可以学习JavaScript 教程 和DHTML 教程


Window Events
窗口事件

只在body和frameset元素中才有效

Attribute
属性
Value
Description
描述
onloadscriptScript to be run when a document loads
装载时
onunloadscriptScript to be run when a document unloads
卸载时


Form Element Events
表单元素事件

Only valid in form elements.
在表单元素中才有效。

Attribute
属性
Value
Description
描述
onchangescriptScript to be run when the element changes
当元素有改变时脚本会执行
onsubmitscriptScript to be run when the form is submitted
当表单提交时...
onresetscriptScript to be run when the form is reset
当表单重置时...
onselectscript Script to be run when the element is selected
元素被选中时...
onblurscript Script to be run when the element loses focus
元素失去焦点时...
onfocusscript Script to be run when the element gets focus
元素得到焦点时...


Keyboard Events
键盘事件

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
描述
onkeydownscript What to do when key is pressed
当键按下时做什么
onkeypressscript What to do when key is pressed and released
当键按下然后释放时做什么
onkeyupscript What to do when key is released
当键释放时做什么


Mouse Events
鼠标事件

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
描述
onclickscript What to do on a mouse click
单击时...
ondblclickscript What to do on a mouse double-click
双击时...
onmousedownscript What to do when mouse button is pressed
按下时...
onmousemovescript What to do when mouse pointer moves
移动时...
onmouseoutscriptWhat to do when mouse pointer moves out of an element
鼠标移开元素时
onmouseoverscriptWhat to do when mouse pointer moves over an element
鼠标在元素上方时
onmouseupscript What to do when mouse button is released
鼠标释放时
 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值