When a user makes mistake, the browser does not give feedback to users unless it is a server response or browser-based error. For example, when you cannot reach a web page, you receive HTML error 404 which means “web page not found“.
There are a lot of server-side errors, a common error is 503 and it means the server cannot provide the service requested. It gives a clear feedback- “Service unavailable“.
- Alert box
- Confirm box
In this example, we are only going to work on alert boxes.
An alert box is a popup box that is a result of an event. Any event like a click, double click, mouse move, etc. can result in an alert box.
So, the alert is an immediate feedback mechanism for some browser-based events.
This is an example of an alert popup for a click event. When a user clicks the button on an HTML form page, an alert will give a message immediately, just like example 1 onload event. To create a page with button use HTML form tags.
Output of #example 1
The output of example 1 is a popup with a message.
Output of #exercise 2
The example 2 HTML page has a form with a single button. When you click on the button an alert box will pop up.
This example shows how an alert box works for an onclick event.