HTML Event Properties (such as: onsubmit)

Source: Internet
Author: User

Learning everything requires a foundation

The basics are important:

One of the new features of HTML 4 is that it enables HTML events to trigger behavior in the browser, for example, when a user clicks on an HTML element to start a piece of JavaScript.

A large number of event handlers are built into the modern browser. These processors monitor specific conditions or user behavior, such as mouse clicks or a browser window that finishes loading an image. By using client-side JavaScript, you can add specific event handlers as attributes to specific labels, and you can execute one or more JavaScript commands or functions when an event occurs.

The value of the event handler is one or a series of Javascript expressions, methods, and function calls separated by semicolons, enclosed in quotation marks. When an event occurs, the browser executes the code. For example, when you move the mouse over a hyperlink, a JavaScript function is started. A special "mouse over" event handler in JavaScript-enabled browser support <a> tags-is known as onmouseover to do the job:

onmouseover="alert(‘Welcome‘);return false"></a>

To learn more about event programming, visit the JavaScript tutorials and DHTML tutorials provided by W3school.

The following table provides the standard event properties that can be inserted into the html/xhtml element to define the event behavior.

Window event (Windows events)

Valid only in the body and frameset elements.

Properties value Description
OnLoad Script Execute script when document is loaded
OnUnload Script Execute script when document is removed
Form elements event (form element events)

Valid only in form elements.

Properties value Description
OnChange Script Execute script when element changes
OnSubmit Script Execute script when form is submitted
OnReset Script Execute script when form is reset
Onselect Script Execute script when element is selected
Onblur Script Execute script when element loses focus
onfocus Script Execute script when element gets focus
Images event (Image events)

This property can be used with the IMG element:

Properties value Description
Onabort Script Execute script when image load is interrupted
Keyboard event (Keyboard events)

Not valid in the following elements: base, BDO, BR, Frame, frameset, head, HTML, iframe, Meta, param, script, style, and title element.

Properties value Description
OnKeyDown Script Execute script when keyboard is pressed
onkeypress Script Execute script when keyboard is pressed and released
OnKeyUp Script Execute script when keyboard is released
Mouse events (Mouse events)

Not valid in the following elements: base, BDO, BR, Frame, frameset, head, HTML, iframe, Meta, param, script, style, and title element.

Properties value Description
OnClick Script Execute script when mouse is clicked
OnDblClick Script Execute script when mouse is double-clicked
OnMouseDown Script Execute script when mouse button is pressed
OnMouseMove Script Execute script when mouse pointer moves
onmouseout Script Execute a script when the mouse pointer moves out of an element
onmouseover Script Execute script when mouse pointer hovers over an element
OnMouseUp Script Execute script when mouse button is released

HTML Event Properties (such as: onsubmit)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.