When to Use Popups / Alerts
- If you want to be absolutely sure they see a message before doing anything on the website.
- You would like to warn the user about something. For example "the following page contains humor not suitable for those under the age of 14."
- An error has occurred and you want to inform the user of the problem.
- When asking users for confirmation of some action. For example, if they have just agreed to sign over the deed to their house and you want to ask them again if they are absolutely positive they want to go through with this decision!
Just for fun, let's suppose that we are making an alert for some website that asks people to hand over the deed to their house. We need to add an alert to be sure these people are in agreement. The following code will add an alert by using an HTML button and the onClick event.
<input type="button" onclick=
"alert('Are you sure you want to give us the deed to your house?')"
Found Something Wrong in this Lesson?
Report a Bug or Comment on This Lesson - Your input is what keeps Tizag improving with time!