0
点赞
收藏
分享

微信扫一扫

HTML 4.0 Event Attributes

GG_lyf 2023-11-09 阅读 39

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.

Attribute

Value

Description

onload

script

Script to be run when a document loads

onunload

script

Script to be run when a document unloads


Form Element Events

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


Keyboard Events

Not valid in base, bdo, br, frame, frameset, head, html, iframe, meta, param, script, style, and title elements.

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


Mouse Events

Not valid in base, bdo, br, frame, frameset, head, html, iframe, meta, param, script, style, title elements.

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

 

 

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 ondblclick = script [CT] The ondblclick onmousedown = script [CT] The onmousedown onmouseup = script [CT] The onmouseup onmouseover = script [CT] The onmouseover onmousemove = script [CT] The onmousemove onmouseout = script [CT] The onmouseout 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 onkeydown = script [CT] The onkeydown onkeyup = script [CT] The onkeyup 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 条评论