1. HTML events
An HTML event is a change in a web page, caused by a user or by the browser. JavaScript can start when an event happens.
`onmouseover` starts a script when the mouse pointer moves over an element. `onmouseout` starts it when the pointer moves away from the element. `onload` starts it when the page has finished loading into the browser.
`onclick` reacts to a mouse click, `onchange` to a change in an input field and `onkeydown` to a key being pressed.
Examiner insight
Worked example 15 marks
Programmers can use JavaScript to make a web page react when an HTML event occurs.
(a) Describe what is meant by an HTML event.
(b) Describe the action that causes each of the following HTML events to start:(i) onmouseover()(ii) onmouseout()(iii) onload()
- 1
(a) an action or change in the web page [1]
- 2
caused by a user or by the browser [1]
- 3
(b)(i) `onmouseover`: the mouse pointer moves over an element [1]
- 4
(ii) `onmouseout`: the mouse pointer moves away from an element [1]
- 5
(iii) `onload`: the page has completely finished loading into the browser [1]