js intro | js popup’s | alert() | tutorialplanet
- alert() method:- we use alert() method to display specific text to user in run-time.
- we find alert boxes in web browser whenever we add some extension to Google web browser.
- According to above screen shot, we knowing alert() method displays alert box with specific message and “ok” button to the user. An alert method is used to make a confirmation from the user, it will take the focus from the current window. Because of this ,we can’t perform any operation on current window.
- alert () have a string type parameter , this parameter value will be displayed on alert box
- whenever we call alert() method in web window or web console .
Confirmation() method :
- Confirmation method displays confirmation message with ok and cancel buttons.
- If the user click on OK button, the confirmation() method will return Boolean value true
- If the user click on cancel button then the confirmation() method will return Boolean value false .
- To easy understanding , we will display messages depending on the return values of the confirmation() method
Example using confirmation() method.
- After invoking the confirmation() method on web console, it will display confirmation dialogue box on web window.
- Whenever the user click on OK or cancel buttons of confirmation box ,then the confirmation dialogue box will be closed automatically and returns the Boolean values.
- Confirmation() method return Boolean value true ,when the user click on OK button of the confirmation dialog box
Prompt() method :-
- prompt() is one of the method same as alert() and confirm() methods .But the main differences among these methods/dialogue boxes are as shown as below.
- alert() method for displaying simple text to user
- confirm() method to make a confirmation from the user with of help OK or cancel buttons and specific text.
- prompt () method, for taking user information ,with help of text box and the remaining functionalities are same.
- when user click on OK button ,the dialogue box will be closed and whatever we enter in textbox it will be returned to web console by prompt() method