The JavaScript alert is a dialogue box that pops up and takes the focus away from the current window and forces the web browser to read the message. You must have JavaScript enabled on your web browser (but most people do these days). Alerts should be very, very rarely used and only when really needed. So this is definitely a case of "Just because you can, doesn't mean you should."
Just for fun, let's suppose that we are making an alert for your site that asks people to hand over $100 every month. 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.
Note: The samples above are simple ones. If you need something a bit more complex, you can do a search for "Javascript Alert Boxes" and can find a lot of examples along with instructions on how to implement them. Also note that an alert box is a function of the operating system, so it cannot be styled with CSS (although there are some jQuery scripts that can make the alert a bit fancier.)