Documentation and Books

Recent site activity

Web Development‎ > ‎JavaScript‎ > ‎

How to display an OK/Cancel message?

The following example will display an OK/Cancel message:

  <html>
<head>
<script language="JavaScript">
function displayOkCancel() {
if (confirm('Are you sure?')) {
alert('User pressed ok.');
} else {
alert('User pressed cancel.');
}
}
</script>
</head>
<body>
<input type="button" onclick="displayOkCancel();" value="Click Me!"/>
</body>
</html>