In our last article we left off with the OnKeyUp function, which is triggered when a user releases a key on the keyboard. We will continue discussing the various JavaScript events in this article, and hopefully finish them in the next tutorial. So grab yourself some coffee and let’s get to work.
OnLoad and OnMouse JavaScript Events (Page 1 of 6 )
But first, let’s preview the beautiful JavaScript Events table again:
Event
What Triggers the Event
OnAbort
Occurs when the loading of an image is interrupted
OnBlur
Occurs when an element loses focus
OnChange
Occurs when the user changes the content of a field
OnClick
Occurs when the user clicks an object
OnDblClick
Occurs when the user double clicks an object
OnError
Occurs when an error occurs while loading a document or an image
OnFocus
Occurs when an element has focus
OnKeyDown
Occurs when a keyboard key is pressed
OnKeyPress
Occurs when a keyboard key is pressed or held down
OnKeyUp
Occurs when a keyboard key is released
OnLoad
Occurs when a page or image has completed loading
OnMouseDown
Occurs when a mouse button is pressed
OnMouseMove
Occurs when the mouse is moved
OnMouseOut
Occurs when the mouse is moved off of an element
OnMouseOver
Occurs when the mouse is moved over an element
OnMouseUp
Occurs when the mouse button is released
OnReset
Occurs when the reset button is clicked
OnResize
Occurs when a window or frame is resized.
OnSelect
Occurs when text is selected
OnSubmit
Occurs when the submit button is clicked
OnUnload
Occurs when the user exits the page
OnLoad
The OnLoad event occurs when either the page or an image is loaded. In the example below, once the page loads we create a pop-up box telling the user that the page has loaded.
<html>
<head>
<script type="text/javascript">
function pageloads()
{
alert ('The page has loaded.')
}
</script>
</head>
<body onload="pageloads()">
</body>
</html>
Supporting HTML tags: <body>, <frame>, <frameset>, <iframe>, <img>, <link>, <script>