May 29, 20222 min

JavaScript Notes: POP UP BOX

Updated: Oct 16, 2022

Mobiprep has created last-minute notes for all topics of Javascript to help you with the revision of concepts for your university examinations. So let’s get started with the lecture notes on javascript.

  1. JavaScript: Introduction

  2. Data Types

  3. Variables

  4. Operators

  5. Functions

  6. Conditional Statements and Loops

  7. Arrays

  8. Objects

  9. DOM Elements

  10. Cookies

  11. Pop Up Box

  12. Exception Handling

Our team has curated a list of the most important questions asked in universities such as DU, DTU, VIT, SRM, IP, Pune University, Manipal University, and many more. The questions are created from the previous year's question papers of colleges and universities.

  1. What is a Pop up box?

  2. What is a difference between alert box and confirmation box?
     

JavaScript Notes: Pop up Box
 

Question 1. What is a Pop up box?

For showing a warning or any other important information to website visitors Popup boxes are used.
 
There are three types of popup box available to use in JavaScript. They are as follows :

  • alert()

  • confirm()

  • prompt()

alert() - JavaScript Message Box To inform or alert the user by displaying some messages in a small dialogue box alert box is used. The alert() method doesn't have an object name in front of it, because the alert() method is part of the window Object .User will have to click "OK" to proceed when an alert box pops up.
 
confirm() - To let the user make a choice confirmation box is used . The user will have to click either "OK" or "Cancel" to proceed the next step when Javascript pops up a confirm box. Depending on what button the user clicks different actions will occur. These course of action can be specified with conditional logic.
 
prompt() - Javascript Prompt Box is used when you want the user to enter an input value before proceeding to the next step. The user should click either "OK" or "Cancel" to proceed after entering an input value when Javascript displays a prompt box. Depending on what exactly the user does with the dialog, the return value of prompt box will be decided.
 

 
The user input string will be returned by prompt method if the user types something, then clicks OK or presses Enter. If the user clicks OK or presses Enter without typing anything into the prompt dialog , the method returns the suggested input, as specified in the second argument passed to prompt. If the user dismisses the dialog by clicking Cancel or pressing Esc or any cancelation action , then in most browsers the prompt method returns null.

Question 2. What is the difference between confirmation box and alert box?


Mobiprep is a one stop solution for all exam preparation needs. Get all exam prep resources at a single platform.

Back to Top


    580
    2