|
|
|
|
|
|
|
Author Rank :
|
|
|
Page Views :
|
768
|
|
Downloads :
|
0
|
|
Rating :
|
Rate it
|
|
Level :
|
Beginner
|
|
|
Whenever a user visit any website, they do lots of things like click on text, images and given links etc. These are examples of what JavaScript calls events. Below is a list of event attributes which are standard, and are supported by most HTML5 tags. Window Events Only used in the <body> element to specify events triggered for a window object.
| Attribute |
Value |
Description |
| onafterprint |
script |
Triggers after the document is printed. |
| onbeforeprint |
script |
Triggers before the document is printed. |
| onbeforeonload |
script |
Triggers before the document loads. |
| onblur |
script |
Triggers when the window loses its focus. |
| onerror |
script |
Triggers when an error occurred. |
| onfocus |
script |
Triggers when the window gets focus. |
| onhaschange |
script |
Triggers when the document has changed. |
| onload |
script |
Triggers when the document loads. |
| onmessage |
script |
Triggers when the message is triggered. |
| onoffline |
script |
Triggers when the document goes offline. |
| ononline |
script |
Triggers when the document comes online. |
| onpagehide |
script |
Triggers when the window is hidden. |
| onpageshow |
script |
Triggers when the window becomes visible. |
| onpopstate |
script |
Triggers when the window's history changes. |
| onredo |
script |
Triggers when the document performs a redo operation. |
| onresize |
script |
Triggers when the window is resized. |
| onstorage |
script |
Triggers when a document loads. |
| onundo |
script |
Triggers when a document performs an undo operation. |
| onunload |
script |
Triggers when the user leaves the document. | Here apart from onblur, onfocus and onload all attributes are new.
Form Events
Applies to all HTML5 elements, but generally used in <form> elements.
| Attribute |
Value |
Description |
| onblur |
script |
Triggers when an element loses focus. |
| onchange |
script |
Triggers when an element changes. |
| oncontextmenuNew |
script |
Triggers when a context menu is triggered. |
| onfocus |
script |
Triggers when an element gets focus. |
| onformchangeNew |
script |
Triggers when a form changes. |
| onforminputNew |
script |
Triggers when a form gets user input. |
| oninputNew |
script |
Triggers when an element gets user input. |
| oninvalidNew |
script |
Triggers when an element is invalid. |
| onreset |
script |
Triggers when a form is reset. Not supported by HTML 5. |
| onselect |
script |
Triggers when an element is selected. |
| onsubmit |
script |
Triggers when a form is submitted. | In form events oncontextmenu, onformchange, oninput, onvalid are new attributes.
Keybord Events
Applies to all HTML5 elements to specify events triggered by a keyboard.
| Attribute |
Value |
Description |
| onkeydown |
script |
Triggers when a key is pressed. |
| onkeypress |
script |
Triggers when a key is pressed and released. |
| onkeyup |
script |
Triggers when a key is released. | Mouse Events
Applies to all HTML5 elements to specify events triggered by a mouse, or similar user actions.
| Attribute |
Value |
Description |
| onclick |
script |
Triggers on a mouse click. |
| ondblclick |
script |
Triggers on a mouse double-click. |
| ondrag |
script |
Triggers when an element is dragged. |
| ondragend |
script |
Triggers at the end of a drag operation. |
| ondragenter |
script |
Triggers when an element has been dragged to a valid drop target. |
| ondragleave |
script |
Triggers when an element leaves a valid drop target. |
| ondragover |
script |
Triggers when an element is being dragged over a valid drop target. |
| ondragstart |
script |
Triggers at the start of a drag operation. |
| ondrop |
script |
Triggers when dragged element is being dropped. |
| onmousedown |
script |
Triggers when a mouse button is pressed. |
| onmousemove |
script |
Triggers when the mouse pointer moves. |
| onmouseout |
script |
Triggers when the mouse pointer moves out of an element. |
| onmouseover |
script |
Triggers when the mouse pointer moves over an element. |
| onmouseup |
script |
Triggers when a mouse button is released. |
| onmousewheel |
script |
Triggers when the mouse wheel is being rotated. |
| onscroll |
script |
Triggers when an element's scrollbar is being scrolled. | Here ondrag, ondragend, ondragenter, ondragleave, ondragover ondragstart, ondrop, onmousewheel and onscroll are new mouse attributes.
Media Events
Applies to all HTML 5 elements, but commonly in media elements, such as audio, embed, img, object, and video to specify events triggered by medias like videos, images and audio.
| Attribute ( New ) |
Value |
Description |
| onabort |
script |
Triggers on an abort event. |
| oncanplay |
script |
Triggers run when media can start play, but might has to stop for buffering. |
| oncanplaythrough |
script |
Triggers when media can be played to the end, without stopping for buffering. |
| ondurationchange |
script |
Triggers when the length of the media is changed. |
| onemptied |
script |
Triggers when a media resource element suddenly becomes empty. |
| onended |
script |
Triggers when media has reach the end. |
| onerror |
script |
Triggers when an error occurs during the loading of an element. |
| onloadeddata |
script |
Triggers when media data is loaded. |
| onloadedmetadata |
script |
Triggers when the duration and other media data of a media element is loaded. |
| onloadstart |
script |
Triggers when the browser starts to load the media data. |
| onpause |
script |
Triggers when media data is paused. |
| onplay |
script |
Triggers when media data is going to start playing. |
| onplaying |
script |
Triggers when media data has start playing. |
| onprogress |
script |
Triggers when the browser is fetching the media data. |
| onratechage |
script |
Triggers when the media data's playing rate has changed. |
| onreadystatechange |
script |
Triggers when the ready-state changes. |
| onseeked |
script |
Triggers when a media element's seeking attribute is no longer true, and the seeking has ended. |
| onseeking |
script |
Triggers when a media element's seeking attribute is true, and the seeking has begun. |
| onstalled |
script |
Triggers when there is an error in fetching media data. |
| onsuspend |
script |
Triggers when the browser has been fetching media data, but stopped before the entire media file was fetched. |
| ontimeupdate |
script |
Triggers when media changes its playing position. |
| onvolumechange |
script |
Triggers when media changes the volume, also when volume is set to mute. |
| onwaiting |
script |
Triggers when media has stopped playing, but is expected to resume. | Summary
In this article we discussed about Event Attributes which are an important part of learning HTML. Nearly every HTML tag uses these attributes to control actions when there is an event that happens on your web page.
|
|
Comment Request!
Thank you for reading this post. Please post your feedback, question, or comments about this post
Here.
|
|
|
|
|
Login
to add your contents and source code to this article
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
C# Consulting is founded in 2002 by the founders of C# Corner. Unlike a traditional
consulting company, our consultants are well-known experts in .NET and many of them
are MVPs, authors, and trainers. We specialize in Microsoft .NET development and
utilize Agile Development and Extreme Programming practices to provide fast pace
quick turnaround results. Our software development model is a mix of Agile Development,
traditional SDLC, and Waterfall models.
|
|
Click here to learn more about C# Consulting. |
|
|
|
|
|
|
|
Introducing MaxV - one click. infinite control. Hyper-V Hosting from MaximumASP.
Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon.
Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees.
As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
|
Dynamic PDF
ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
|
Nevron Chart for .NET 2010.1 Now Available
The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
|
ASP.NET 4 Hosting
Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites – Click Here!
|
|
|
|
|
|
|
|
|
|
|
|
|