Javascript Notes
JavaScript
Data Types
Variables
Operators
Functions
Conditional Statements and Loops
Arrays
Objects
DOM Elements
Cookies
Pop Up Box
Exception Handling
Heading
Q
1
What is a Pop up box?
Ans
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()
1-alert() - JavaScript MessageBox 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.
2-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 ifferent actions will occur. These course of action can be specified with conditional logic.
3-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.
Q
2
What is the difference between confirmation box and alert box?
Ans