An alert box is a small dialog box that provides a user with important information. The most common uses are to inform ("alert box") the user about errors (e.g., especially with form validation), to provide simple help messages, or to require confirmation ("confirmation box") before allowing certain website actions. You’ll often see the confirmation box used before the applications performs a task that cannot be easily reversed, for example charging a credit card or deleting content.
Note the use of
\n – a forward slash is used before all special characters and the n tells the alert box to insert a carriage return (line break).
In this case, a "no" (cancel) answer does nothing, but a "yes" (OK) reply takes you to the URL specified.
<a href="http://www.linkhere.com" onClick="return myjsfunction();)">Confirm Me</a>
Personally, I use both of these regularly, especially the confirmation box on my administrative pages that offer a delete option – it has prevented me from accidentally deleting database records on numerous occasions!