Part 6 - Getting Input from Users
Data may be received from the user with the window.prompt command:
variable = window.prompt(display text, initial value)
This script ran when the current page loaded:
Another example of entering data from a prompt:
You can also display a message to the user with the window.alert command:
Click here to try it out.
Pros and Cons
- Quick way to collect user input
- Disrupts interface
- Limited and restricted
Better alternative: HTML form tags.