KEMBAR78
Html events with javascript | PPTX
HTML EVENTS WITH JAVA
SCRIPT
S.B.S.Younus, M.Sc., M.Phil., NET.,
Assistant Professor,
Department of Computer Science,
KR College of Arts and Science,
Kovilpatti.
HTML Events
 HTML stands for Hypertext Markup Language
 HTML events are "things" that happen to
HTML elements
 When JavaScript is used in HTML pages,
JavaScript can "react" on these events
 An HTML event can be something the browser
does, or something a user does
 Examples of HTML events:
An HTML web page has finished loading
An HTML input field was changed
An HTML button was clicked
 Often, when events happen, you may want to
do something
 JavaScript lets you execute code when events
are detected
 HTML allows event handler attributes, with
JavaScript code, to be added to HTML
elements
onclick Event
 This is the most frequently used event type
 It occurs when a user clicks the left button
of his mouse
 We can put our validation, warning etc.,
against this event type
Example Script
 The following script (EventJS.html) creates a
webpage with single button. When you press
the button it will show the dialog box
 When you click the button the onclick() event
will occur
 In the following script the red colored text
refers the javascript
 Type the following script in a notepad and
save it with the extension .html. After this, just
double click the file, it will run on the browser.
Script – EventJS.html
<html>
<head>
<title>
Java Script Events
</title>
<script type = “text/javascript”>
function saySalaam()
{
alert(“Asalaam")
}
</script>
</head>
<body>
<input type = "button" onclick = “saySalaam()" value = “Click Here" />
</form>
</body>
</html>
Output – Before Press Click
Button
Output – After Press Click
Button
HTML 5 Standard Events
Html events with javascript
Html events with javascript
Html events with javascript
Html events with javascript
Html events with javascript
Html events with javascript
Html events with javascript
Html events with javascript
Html events with javascript
Html events with javascript

Html events with javascript

  • 1.
    HTML EVENTS WITHJAVA SCRIPT S.B.S.Younus, M.Sc., M.Phil., NET., Assistant Professor, Department of Computer Science, KR College of Arts and Science, Kovilpatti.
  • 2.
    HTML Events  HTMLstands for Hypertext Markup Language  HTML events are "things" that happen to HTML elements  When JavaScript is used in HTML pages, JavaScript can "react" on these events  An HTML event can be something the browser does, or something a user does
  • 3.
     Examples ofHTML events: An HTML web page has finished loading An HTML input field was changed An HTML button was clicked  Often, when events happen, you may want to do something  JavaScript lets you execute code when events are detected  HTML allows event handler attributes, with JavaScript code, to be added to HTML elements
  • 4.
    onclick Event  Thisis the most frequently used event type  It occurs when a user clicks the left button of his mouse  We can put our validation, warning etc., against this event type
  • 5.
    Example Script  Thefollowing script (EventJS.html) creates a webpage with single button. When you press the button it will show the dialog box  When you click the button the onclick() event will occur  In the following script the red colored text refers the javascript  Type the following script in a notepad and save it with the extension .html. After this, just double click the file, it will run on the browser.
  • 6.
    Script – EventJS.html <html> <head> <title> JavaScript Events </title> <script type = “text/javascript”> function saySalaam() { alert(“Asalaam") } </script> </head> <body> <input type = "button" onclick = “saySalaam()" value = “Click Here" /> </form> </body> </html>
  • 7.
    Output – BeforePress Click Button
  • 8.
    Output – AfterPress Click Button
  • 9.