Using the prompt box:
The prompt box is used to input a value from the user. It contains a textbox, OK and Cancel buttons. The user has to click either OK or Cancel button to continue the execution of the code after entering the input value. If OK button is clicked, the input value is returned. Otherwise, box returns null value.
Demo:
- Create a document called promptBox.html
- Write the following code:
- Execute the script by Opening the file in the Web Browser. If you are using Internet Explore click on “Allow Blocked Content” to allow the script to execute and you are using Mozilla Firefox then click on allow “ActiveX Controls”.
When user enters the name and hits the OK button:
When the user clicks on Cancel button.