SlideShare a Scribd company logo
Javascript Event Handling
Chapter 9
Events
 Things that happen within the scope of the browser
 User clicks an element - onclick
 Mouse pointer moves
 Web page finishes loading - onload
 HTML input field changed - onchange
 Any HTML element has changed - onchange
 User moves mouse over an element – onmouseover
 User moves mouse away from an element - onmouseout
 User pushes a keyboard key – onkeydown
 https://www.w3schools.com/jsref/dom_obj_event.asp
Events
 Event Handler – Javascript that processes when event
takes place
<a href=“http://google.com/”
onmouseover=“alert(‘you moved the mouse over a
link’);”>
This is a link.</a>
 Note the use of ‘ and “
<a href="#bottom" onmouseover="doIt();">Move
the mouse over this link.</a>
LiveCode
 Write a javascript program that allows the user to
enter text into an input field. Hit a button that checks
to see if the text is a palindrome. Display an
appropriate message.
LiveCode  Display random numbers
EventHandlers
 Best to define event handlers as functions
function mousealert() (
a1ert("You clicked the mouse!"); }
document.onmousedown = mousealert;
 Better way
<a href="http://www.google.com/" id="link1">
var 1ink1_obj = document.getBlementById("linkl");
link1_obj.onc1ick = myCustomFunction;
MultipleEvent
Handlers
 There are times you may want more than one event
handler to take place for a given event
 Solution: listeners
<body onkeypress="getKey(event);">
Function getKey(e) {
// code to process event }
BrowserIssues
 Firefox, Safari, Chrome – an Event object is
automatically passed in to the event handler
 Internet Explorer – most recent event is stored in
window.event
function getKey(e) {
if (!e) e = window.event;
// code to process event
}

More Related Content

PPTX
Html events with javascript
DOCX
Make money without a Investment
PDF
Better than google.
PPT
Js events
PPTX
Html web workers
PPTX
Html Server Anchor Control CS
PDF
Better than google. (1)
PDF
Autopilot
Html events with javascript
Make money without a Investment
Better than google.
Js events
Html web workers
Html Server Anchor Control CS
Better than google. (1)
Autopilot

What's hot (20)

DOCX
See how i make 300$ daily
DOC
Autopilotnew money money $$
PDF
Autopilot method $
PPTX
Autopilot (1)
KEY
5 Tips for Writing Better JavaScript
PDF
Cash Kingdom Autopilot income 2017
PPTX
Dream dayppt
DOCX
Earn money auto pilot
PPTX
Make money on autopilot
PPTX
RPEMS Google Drive Access
PDF
Como ganar dinero gratis!
PDF
Better than google
PDF
Autopilot
PPTX
Html Server Anchor Control VB
DOCX
Right one
PDF
Autopilot method
DOCX
Autopilot method
DOCX
Something amazing is happening...
PDF
EARN $300 DAILY AUTOPILOT NO INVESTMENT EASY METHOD
DOCX
Autopilot
See how i make 300$ daily
Autopilotnew money money $$
Autopilot method $
Autopilot (1)
5 Tips for Writing Better JavaScript
Cash Kingdom Autopilot income 2017
Dream dayppt
Earn money auto pilot
Make money on autopilot
RPEMS Google Drive Access
Como ganar dinero gratis!
Better than google
Autopilot
Html Server Anchor Control VB
Right one
Autopilot method
Autopilot method
Something amazing is happening...
EARN $300 DAILY AUTOPILOT NO INVESTMENT EASY METHOD
Autopilot
Ad

Similar to Upstate CSCI 450 WebDev Chapter 9 (20)

PDF
JavaScript - Chapter 11 - Events
PPTX
Event In JavaScript
PPTX
types of events in JS
PPTX
5 .java script events
PPTX
JavaScript_Event_Handling_Presentation.pptx
PPTX
Javascript event handler
PPTX
DHTML - Events & Buttons
PPTX
FYBSC IT Web Programming Unit III Events and Event Handlers
PPTX
JavaScript_Event_Handling_Updated_______
PPT
JavaScript: Events Handling
PDF
Web 5 | JavaScript Events
PPTX
Lesson 205 07 oct13-1500-ay
PPTX
Upstate CSCI 450 WebDev Chapter 4
PPTX
JavaScript_Events.pptx
PDF
Introducing jQuery
PPTX
[SoftServe IT Academy] - JavaScript Events
PPTX
javascript-events_zdgdsggdgdgdsggdgdgd.pptx
PPTX
Upstate CSCI 450 WebDev Chapter 4
PDF
JavaScript From Scratch: Events
PDF
Javascript Browser Events.pdf
JavaScript - Chapter 11 - Events
Event In JavaScript
types of events in JS
5 .java script events
JavaScript_Event_Handling_Presentation.pptx
Javascript event handler
DHTML - Events & Buttons
FYBSC IT Web Programming Unit III Events and Event Handlers
JavaScript_Event_Handling_Updated_______
JavaScript: Events Handling
Web 5 | JavaScript Events
Lesson 205 07 oct13-1500-ay
Upstate CSCI 450 WebDev Chapter 4
JavaScript_Events.pptx
Introducing jQuery
[SoftServe IT Academy] - JavaScript Events
javascript-events_zdgdsggdgdgdsggdgdgd.pptx
Upstate CSCI 450 WebDev Chapter 4
JavaScript From Scratch: Events
Javascript Browser Events.pdf
Ad

More from DanWooster1 (20)

PPTX
Upstate CSCI 540 Agile Development
PPTX
Upstate CSCI 540 Unit testing
PPTX
Upstate CSCI 450 WebDev Chapter 3
PPTX
Upstate CSCI 450 WebDev Chapter 2
PPTX
Upstate CSCI 450 WebDev Chapter 1
PPT
Upstate CSCI 525 Data Mining Chapter 3
PPT
Upstate CSCI 525 Data Mining Chapter 2
PPT
Upstate CSCI 525 Data Mining Chapter 1
PPTX
Upstate CSCI 200 Java Chapter 8 - Arrays
PPTX
Upstate CSCI 200 Java Chapter 7 - OOP
PPTX
CSCI 200 Java Chapter 03 Using Classes
PPTX
CSCI 200 Java Chapter 02 Data & Expressions
PPTX
CSCI 200 Java Chapter 01
PPTX
CSCI 238 Chapter 08 Arrays Textbook Slides
PPTX
Chapter 6 - More conditionals and loops
PPTX
Upstate CSCI 450 jQuery
PPTX
Upstate CSCI 450 PHP Chapters 5, 12, 13
PPTX
Upstate CSCI 450 PHP
PPTX
CSCI 238 Chapter 07 - Classes
PPTX
C++ Chapter 11 OOP - Part 7
Upstate CSCI 540 Agile Development
Upstate CSCI 540 Unit testing
Upstate CSCI 450 WebDev Chapter 3
Upstate CSCI 450 WebDev Chapter 2
Upstate CSCI 450 WebDev Chapter 1
Upstate CSCI 525 Data Mining Chapter 3
Upstate CSCI 525 Data Mining Chapter 2
Upstate CSCI 525 Data Mining Chapter 1
Upstate CSCI 200 Java Chapter 8 - Arrays
Upstate CSCI 200 Java Chapter 7 - OOP
CSCI 200 Java Chapter 03 Using Classes
CSCI 200 Java Chapter 02 Data & Expressions
CSCI 200 Java Chapter 01
CSCI 238 Chapter 08 Arrays Textbook Slides
Chapter 6 - More conditionals and loops
Upstate CSCI 450 jQuery
Upstate CSCI 450 PHP Chapters 5, 12, 13
Upstate CSCI 450 PHP
CSCI 238 Chapter 07 - Classes
C++ Chapter 11 OOP - Part 7

Recently uploaded (20)

PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
System and Network Administraation Chapter 3
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PPTX
history of c programming in notes for students .pptx
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PDF
Softaken Excel to vCard Converter Software.pdf
PPTX
Transform Your Business with a Software ERP System
PDF
How Creative Agencies Leverage Project Management Software.pdf
PPTX
Operating system designcfffgfgggggggvggggggggg
PDF
Digital Strategies for Manufacturing Companies
PPTX
L1 - Introduction to python Backend.pptx
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Design an Analysis of Algorithms I-SECS-1021-03
Upgrade and Innovation Strategies for SAP ERP Customers
Internet Downloader Manager (IDM) Crack 6.42 Build 41
System and Network Administraation Chapter 3
VVF-Customer-Presentation2025-Ver1.9.pptx
2025 Textile ERP Trends: SAP, Odoo & Oracle
wealthsignaloriginal-com-DS-text-... (1).pdf
history of c programming in notes for students .pptx
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
Softaken Excel to vCard Converter Software.pdf
Transform Your Business with a Software ERP System
How Creative Agencies Leverage Project Management Software.pdf
Operating system designcfffgfgggggggvggggggggg
Digital Strategies for Manufacturing Companies
L1 - Introduction to python Backend.pptx
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
Which alternative to Crystal Reports is best for small or large businesses.pdf

Upstate CSCI 450 WebDev Chapter 9

  • 2. Events  Things that happen within the scope of the browser  User clicks an element - onclick  Mouse pointer moves  Web page finishes loading - onload  HTML input field changed - onchange  Any HTML element has changed - onchange  User moves mouse over an element – onmouseover  User moves mouse away from an element - onmouseout  User pushes a keyboard key – onkeydown  https://www.w3schools.com/jsref/dom_obj_event.asp
  • 3. Events  Event Handler – Javascript that processes when event takes place <a href=“http://google.com/” onmouseover=“alert(‘you moved the mouse over a link’);”> This is a link.</a>  Note the use of ‘ and “ <a href="#bottom" onmouseover="doIt();">Move the mouse over this link.</a>
  • 4. LiveCode  Write a javascript program that allows the user to enter text into an input field. Hit a button that checks to see if the text is a palindrome. Display an appropriate message.
  • 5. LiveCode  Display random numbers
  • 6. EventHandlers  Best to define event handlers as functions function mousealert() ( a1ert("You clicked the mouse!"); } document.onmousedown = mousealert;  Better way <a href="http://www.google.com/" id="link1"> var 1ink1_obj = document.getBlementById("linkl"); link1_obj.onc1ick = myCustomFunction;
  • 7. MultipleEvent Handlers  There are times you may want more than one event handler to take place for a given event  Solution: listeners <body onkeypress="getKey(event);"> Function getKey(e) { // code to process event }
  • 8. BrowserIssues  Firefox, Safari, Chrome – an Event object is automatically passed in to the event handler  Internet Explorer – most recent event is stored in window.event function getKey(e) { if (!e) e = window.event; // code to process event }