The JavaScript confirm alert box differs through a regular alert box in which it provides two choices to the user, OK & Cancel. Typically, you'll see confirmation boxes utilized on links where the destination is outside of the domain of the page you are at present on or to alert you of potentially objectionable material. The following instance will display a confirmation alert box while either a link or form button is clicked. Once either OK or Cancel is chosen an alert box will follow to display that was chosen.
<html>
<body bgcolor="#FFFFFF">
<title>CodeAve.com(JavaScript: Confirm Alert Box)</title>
<script language="JavaScript">
<!--
function confirm_entry()
{
input_box=confirm("Click on OK or Cancel to Continue");
if (input_box==true)
{
// Output while OK is clicked alert ("You clicked OK");
}
-->
else
}
{
// Output while Cancel is clicked alert ("You clicked cancel");
}
</script>
Click <a href="JavaScript:confirm_entry()">here</a>
<p>
<form onSubmit="confirm_entry()">
<input type="submit" >
</form>
</body>
</html>