当前位置:AJAX >> WebDev >> XHTML >>  浏览文章
保护视力色: 杏仁黄 秋叶褐 胭脂红 芥末绿 天蓝 雪青 灰 银河白(默认)
字体:[ ]

XHTML 事件

    2006-10-04
对于HTML4.0来说能够在浏览器中让HTML事件触发行为是新功能,如用户点击某元素会触发某JS。下面是一列可以插入HTML标签中定义事件动作的属性
Window 事件
只在body和frameset元素中有效

属性 值 描述
onload script Script to be run when a document loads  
onunload script Script to be run when a document unloads  

表单(form)元素事件
只在表单元素中有效

属性 值 描述
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  

按键事件
在 base, bdo, br, frame, frameset, head, html, iframe, meta, param, script, style, 和 title 元素中无效

属性 值 描述
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  

鼠标事件
在 base, bdo, br, frame, frameset, head, html, iframe, meta, param, script, style, 和 title元素中无效

属性 值 描述
onclick script  What to do on a mouse click  
ondblclick script  What to do on a mouse doubleclick  
onmousedown script  What to do when mouse button is pressed  
onmousemove script  What to do when mouse pointer moves  
onmouseover script What to do when mouse pointer moves over an element  
onmouseout script What to do when mouse pointer moves out of an element  
onmouseup script  What to do when mouse button is released