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

What's hot (20)

DOCX
See how i make 300$ daily
vision2020166
 
DOC
Autopilotnew money money $$
KamilBejm1
 
PDF
Autopilot method $
RyanRoberts127
 
PPTX
Autopilot (1)
Marc Taylor
 
KEY
5 Tips for Writing Better JavaScript
Nael El Shawwa
 
PDF
Cash Kingdom Autopilot income 2017
Mohamed Rafat
 
PPTX
Dream dayppt
joyousone1104
 
DOCX
Earn money auto pilot
voltrik
 
PPTX
Make money on autopilot
Devon Taylor
 
PPTX
RPEMS Google Drive Access
50PagesToLife
 
PDF
Como ganar dinero gratis!
Fernando Ramos Inostroza
 
PDF
Better than google
clevanisilva
 
PDF
Autopilot
FloordeWit1
 
PPTX
Html Server Anchor Control VB
sunmitraeducation
 
DOCX
Right one
Chris Jones
 
PDF
Autopilot method
Fartizy
 
DOCX
Autopilot method
mexico100208
 
DOCX
Something amazing is happening...
Project Life Success
 
PDF
EARN $300 DAILY AUTOPILOT NO INVESTMENT EASY METHOD
Fatima1567
 
DOCX
Autopilot
Okan Feim
 
See how i make 300$ daily
vision2020166
 
Autopilotnew money money $$
KamilBejm1
 
Autopilot method $
RyanRoberts127
 
Autopilot (1)
Marc Taylor
 
5 Tips for Writing Better JavaScript
Nael El Shawwa
 
Cash Kingdom Autopilot income 2017
Mohamed Rafat
 
Dream dayppt
joyousone1104
 
Earn money auto pilot
voltrik
 
Make money on autopilot
Devon Taylor
 
RPEMS Google Drive Access
50PagesToLife
 
Como ganar dinero gratis!
Fernando Ramos Inostroza
 
Better than google
clevanisilva
 
Autopilot
FloordeWit1
 
Html Server Anchor Control VB
sunmitraeducation
 
Right one
Chris Jones
 
Autopilot method
Fartizy
 
Autopilot method
mexico100208
 
Something amazing is happening...
Project Life Success
 
EARN $300 DAILY AUTOPILOT NO INVESTMENT EASY METHOD
Fatima1567
 
Autopilot
Okan Feim
 

Similar to Upstate CSCI 450 WebDev Chapter 9 (20)

PDF
JavaScript - Chapter 11 - Events
WebStackAcademy
 
PPTX
types of events in JS
chauhankapil
 
PPTX
5 .java script events
chauhankapil
 
PPTX
Event In JavaScript
ShahDhruv21
 
PDF
Javascript Browser Events.pdf
ShubhamChaurasia88
 
PPTX
Chapter 11
application developer
 
PDF
Java script browser objects 1
H K
 
PDF
JavaScript
tutorialsruby
 
PDF
JavaScript
tutorialsruby
 
PPTX
Lab #2: Introduction to Javascript
Walid Ashraf
 
PPTX
Javascript event handler
Jesus Obenita Jr.
 
PPTX
Html5 events
AbhishekMondal42
 
PPTX
javascript-events_zdgdsggdgdgdsggdgdgd.pptx
NetajiGandi1
 
PPTX
Client side scripting using Javascript
Bansari Shah
 
KEY
Reacting to a Virtual World
Jaime Christine Perez
 
PPT
Less03 2 e_testermodule_2
Suresh Mishra
 
PPT
Java script
fahhadalghamdi
 
PDF
Javascript #8 : événements
Jean Michel
 
PPTX
DHTML - Events & Buttons
Deep Patel
 
PPTX
Client Web
Markiyan Matsekh
 
JavaScript - Chapter 11 - Events
WebStackAcademy
 
types of events in JS
chauhankapil
 
5 .java script events
chauhankapil
 
Event In JavaScript
ShahDhruv21
 
Javascript Browser Events.pdf
ShubhamChaurasia88
 
Java script browser objects 1
H K
 
JavaScript
tutorialsruby
 
JavaScript
tutorialsruby
 
Lab #2: Introduction to Javascript
Walid Ashraf
 
Javascript event handler
Jesus Obenita Jr.
 
Html5 events
AbhishekMondal42
 
javascript-events_zdgdsggdgdgdsggdgdgd.pptx
NetajiGandi1
 
Client side scripting using Javascript
Bansari Shah
 
Reacting to a Virtual World
Jaime Christine Perez
 
Less03 2 e_testermodule_2
Suresh Mishra
 
Java script
fahhadalghamdi
 
Javascript #8 : événements
Jean Michel
 
DHTML - Events & Buttons
Deep Patel
 
Client Web
Markiyan Matsekh
 
Ad

More from DanWooster1 (20)

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

Recently uploaded (20)

PDF
Add Background Images to Charts in IBM SPSS Statistics Version 31.pdf
Version 1 Analytics
 
PPTX
Home Care Tools: Benefits, features and more
Third Rock Techkno
 
PPTX
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
PDF
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
PDF
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
PPTX
Coefficient of Variance in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PPTX
Homogeneity of Variance Test Options IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PPTX
OpenChain @ OSS NA - In From the Cold: Open Source as Part of Mainstream Soft...
Shane Coughlan
 
PDF
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
PPTX
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
PDF
How to Hire AI Developers_ Step-by-Step Guide in 2025.pdf
DianApps Technologies
 
PDF
AOMEI Partition Assistant Crack 10.8.2 + WinPE Free Downlaod New Version 2025
bashirkhan333g
 
PPTX
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
PDF
Technical-Careers-Roadmap-in-Software-Market.pdf
Hussein Ali
 
PPTX
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
PPTX
Comprehensive Risk Assessment Module for Smarter Risk Management
EHA Soft Solutions
 
PDF
Driver Easy Pro 6.1.1 Crack Licensce key 2025 FREE
utfefguu
 
PDF
TheFutureIsDynamic-BoxLang witch Luis Majano.pdf
Ortus Solutions, Corp
 
PPTX
Help for Correlations in IBM SPSS Statistics.pptx
Version 1 Analytics
 
PDF
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
Add Background Images to Charts in IBM SPSS Statistics Version 31.pdf
Version 1 Analytics
 
Home Care Tools: Benefits, features and more
Third Rock Techkno
 
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
Automate Cybersecurity Tasks with Python
VICTOR MAESTRE RAMIREZ
 
Coefficient of Variance in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Homogeneity of Variance Test Options IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
OpenChain @ OSS NA - In From the Cold: Open Source as Part of Mainstream Soft...
Shane Coughlan
 
Digger Solo: Semantic search and maps for your local files
seanpedersen96
 
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
How to Hire AI Developers_ Step-by-Step Guide in 2025.pdf
DianApps Technologies
 
AOMEI Partition Assistant Crack 10.8.2 + WinPE Free Downlaod New Version 2025
bashirkhan333g
 
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
Technical-Careers-Roadmap-in-Software-Market.pdf
Hussein Ali
 
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
Comprehensive Risk Assessment Module for Smarter Risk Management
EHA Soft Solutions
 
Driver Easy Pro 6.1.1 Crack Licensce key 2025 FREE
utfefguu
 
TheFutureIsDynamic-BoxLang witch Luis Majano.pdf
Ortus Solutions, Corp
 
Help for Correlations in IBM SPSS Statistics.pptx
Version 1 Analytics
 
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 

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 }