1 of 11

Web Technologies

Java Script Events & Popup boxes

Smt M.Jeevana Sujitha

Assistant Professor

Department of Computer Science and Engineering

SRKR Engineering College, Bhimavaram, A.P. - 534204

2 of 11

OBJECTIVES

The Objectives of this lecture are

  • To learn about JS Events.
  • To learn about JS Popup boxes.

3 of 11

Java Script Events

  • Event is an activity that represents a change in the environment.
  • Javascript events can be divided into 3 types
  • Onclick
  • Onsubmit
  • Onload

4 of 11

Java Script Events

  • Onclick Event: This is the most frequently used event type which occurs when a user click the left button of mouse.
  • We can put our validation, warning against this event.

5 of 11

Java Script Events

  • Onsubmit Event: This is an event that occurs when we try to submit a form.
  • We can put our validation, warning against this event.

6 of 11

Java Script Events

  • Onload Event: This event activated as soon as the web page gets loaded in the browsers window.
  • It is used to check visitors browser type and version of the webpage.

7 of 11

Java Script Popup boxes

  • Java script has 3 kinds of popup boxes.
  • Alert box
  • Confirm box
  • Prompt box

8 of 11

Java Script Popup boxes

  • Alert box: An alert box is used if we want to execute make sure information comes through to the user.
  • When an alert box pops up the user will have to click “ok” to proceed.
  • Syntax:

alert(“some text”);

9 of 11

Java Script Popup boxes

  • Confirm box: A confirm box is used if we want the user to verify or accept something.
  • When a confirm box pops up, the user will have to click either “ok” or “cancel” to proceed.
  • If the user clicks on “ok” the box returns true.
  • If the user clicks on “cancel” it returns false.
  • Syntax:

confirm(“some text”);

10 of 11

Java Script Popup boxes

  • Prompt box: A prompt box is used if we want the user to input a value before entering a page.
  • When a prompt box pops up, the user will have to click either “ok” or “cancel” to proceed after entering an input value.
  • If the user clicks on “ok” the box returns the entered value.
  • If the user clicks on “cancel” it returns null.
  • Syntax:

confirm(“some text”, ”default value”);

11 of 11

THANK YOU