HTML 4.0 Event Attributes

HTML 4.0 Event Attributes


New to HTML 4.0 is 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.


 

Window Events

Only valid in body and frameset elements.

AttributeValueDescription
onloadscriptScript to be run when a document loads
onunloadscriptScript to be run when a document unloads


Form Element Events

Only valid in form elements.

AttributeValueDescription
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.

AttributeValueDescription
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.

AttributeValueDescription
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

 

 

Attribute definitions

onload = script [CT]
The onload event occurs when the user agent finishes loading a window or all frames within a FRAMESET. This attribute may be used with BODY and FRAMESET elements.
onunload = script [CT]
The onunload event occurs when the user agent removes a document from a window or frame. This attribute may be used with BODY and FRAMESET elements.
onclick = script [CT]
The onclick event occurs when the pointing device button is clicked over an element. This attribute may be used with most elements.
ondblclick = script [CT]
The ondblclick event occurs when the pointing device button is double clicked over an element. This attribute may be used with most elements.
onmousedown = script [CT]
The onmousedown event occurs when the pointing device button is pressed over an element. This attribute may be used with most elements.
onmouseup = script [CT]
The onmouseup event occurs when the pointing device button is released over an element. This attribute may be used with most elements.
onmouseover = script [CT]
The onmouseover event occurs when the pointing device is moved onto an element. This attribute may be used with most elements.
onmousemove = script [CT]
The onmousemove event occurs when the pointing device is moved while it is over an element. This attribute may be used with most elements.
onmouseout = script [CT]
The onmouseout event occurs when the pointing device is moved away from an element. This attribute may be used with most elements.
onfocus = script [CT]
The onfocus event occurs when an element receives focus either by the pointing device or by tabbing navigation. This attribute may be used with the following elements: A, AREA, LABEL, INPUT, SELECT, TEXTAREA, and BUTTON.
onblur = script [CT]
The onblur event occurs when an element loses focus either by the pointing device or by tabbing navigation. It may be used with the same elements as onfocus.
onkeypress = script [CT]
The onkeypress event occurs when a key is pressed and released over an element. This attribute may be used with most elements.
onkeydown = script [CT]
The onkeydown event occurs when a key is pressed down over an element. This attribute may be used with most elements.
onkeyup = script [CT]
The onkeyup event occurs when a key is released over an element. This attribute may be used with most elements.
onsubmit = script [CT]
The onsubmit event occurs when a form is submitted. It only applies to the FORM element.
onreset = script [CT]
The onreset event occurs when a form is reset. It only applies to the FORM element.
onselect = script [CT]
The onselect event occurs when a user selects some text in a text field. This attribute may be used with the INPUT and TEXTAREA elements.
onchange = script [CT]
The onchange event occurs when a control loses the input focus and its value has been modified since gaining focus. This attribute applies to the following elements: INPUT, SELECT, and TEXTAREA.

REF:

http://www.w3.org/TR/REC-html40/interact/scripts.html

http://www.w3schools.com/Html/html_eventattributes.asp

http://msdn.microsoft.com/en-us/library/ms533051.aspx

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值