CodesJava

Easy learning with example program codes

Javascript events example

Event:

Happening of something is known as event.

JavaScript event:

JavaScript uses DOM events for interacting with HTML when a webpage is manipulated by a user or browser. Clicking a button, keypress etc. are the examples of an event.

Example:

<!DOCTYPE html>
<html>
<body> 
<script>    
function sayHello() {
   alert("Onclick event.")
} 
</script>   
<p>Click Say Hello button and see result.</p>      
<form>
 <input type="button" onclick="sayHello()" value="Say Hello" />
</form>
</body>
</html>

Try it:

on jsbin.com
 

JavaScript events list:

Attribute  Description
OfflineTriggers when the document goes offline
OnabortTriggers on an abort event
onafterprintTriggers after the document is printed
onbeforeonloadTriggers before the document loads
onbeforeprintTriggers before the document is printed
onblurTriggers when the window loses focus
oncanplayTriggers when media can start play, but might has to stop for buffering
oncanplaythroughTriggers when media can be played to the end, without stopping for buffering
onchangeTriggers when an element changes
onclickTriggers on a mouse click
oncontextmenuTriggers when a context menu is triggered
ondblclickTriggers on a mouse double-click
ondragTriggers when an element is dragged
ondragendTriggers at the end of a drag operation
ondragenterTriggers when an element has been dragged to a valid drop target
ondragleaveTriggers when an element is being dragged over a valid drop target
ondragoverTriggers at the start of a drag operation
ondragstartTriggers at the start of a drag operation
ondropTriggers when dragged element is being dropped
ondurationchangeTriggers when the length of the media is changed
onemptiedTriggers when a media resource element suddenly becomes empty.
onendedTriggers when media has reach the end
onerrorTriggers when an error occur
onfocusTriggers when the window gets focus
onformchangeTriggers when a form changes
onforminputTriggers when a form gets user input
onhaschangeTriggers when the document has change
oninputTriggers when an element gets user input
oninvalidTriggers when an element is invalid
onkeydownTriggers when a key is pressed
onkeypressTriggers when a key is pressed and released
onkeyupTriggers when a key is released
onloadTriggers when the document loads
onloadeddataTriggers when media data is loaded
onloadedmetadataTriggers when the duration and other media data of a media element is loaded
onloadstartTriggers when the browser starts to load the media data
onmessageTriggers when the message is triggered
onmousedownTriggers when a mouse button is pressed
onmousemoveTriggers when the mouse pointer moves
onmouseoutTriggers when the mouse pointer moves out of an element
onmouseoverTriggers when the mouse pointer moves over an element
onmouseupTriggers when a mouse button is released
onmousewheelTriggers when the mouse wheel is being rotated
onofflineTriggers when the document goes offline
onoineTriggers when the document comes online
ononlineTriggers when the document comes online
onpagehideTriggers when the window is hidden
onpageshowTriggers when the window becomes visible
onpauseTriggers when media data is paused
onplayTriggers when media data is going to start playing
onplayingTriggers when media data has start playing
onpopstateTriggers when the window’s history changes
onprogressTriggers when the browser is fetching the media data
onratechangeTriggers when the media data’s playing rate has changed
onreadystatechangeTriggers when the ready-state changes
onredoTriggers when the document performs a redo
onresizeTriggers when the window is resized
onscrollTriggers when an element’s scrollbar is being scrolled
onseekedTriggers when a media element’s seeking attribute is no longer true, and the seeking has ended
onseekingTriggers when a media element’s seeking attribute is true, and the seeking has begun
onselectTriggers when an element is selected
onstalledTriggers when there is an error in fetching media data
onstorageTriggers when a document loads
onsubmitTriggers when a form is submitted
onsuspendTriggers when the browser has been fetching media data, but stopped before the entire media file was fetched
ontimeupdateTriggers when media changes its playing position
onundoTriggers when a document performs an undo
onunloadTriggers when the user leaves the document
onvolumechangeTriggers when media changes the volume, also when volume is set to “mute”
onwaitingTriggers when media has stopped playing, but is expected to resume

 

Please follow and like us:








Copyright © 2019 CodesJava DMCA.com Protection Status