Confirm() Function
See also
Examples
- JavaScript
Confirm() - example of using a JavaScript confirm() method. Returns
a boolean true or false.
Ex: <a href="javascript:
confirm('When finished, click OK'); void('')">JavaScript Confirm()</a>
-
Results
Example - Showing how to capture the results. Returns a
boolean true or false.
Ex: <a href="javascript:
alert('Your choice was: ' + confirm('When finished, click OK') );
void('')">Results Example</a>
-
If Example - Showing how to capture the results. Returns a
boolean true or false.
Ex: <a href="javascript: if (confirm('Continue?')) {
alert('You chose true') } else { alert('You chose false.') }; void('')">
-
Confirm OK, then goto URL (uses onclick()) - Confirm, then next web
page - If you press 'OK', then you will launch another web page.
Ex: <a href="ex_confirm_continuepressed.htm" onclick = "if (!
confirm('Continue?')) return false;">
-
Confirm OK, then popup a new window (uses onclick()) - Confirm, then next web
page - If you press 'OK', then you will launch another web page.
Ex: <a href="ex_confirm_continuepressed.htm" onclick = "if (!
confirm('Continue?')) return false;">
-
Confirm OK, then goto a URL (uses window.location.href) - Confirm, then next web
page - If you press 'OK', then you will launch another web page.
Ex: <a href="javascript: if (confirm('Continue?')) {
window.location.href='ex_confirm_continuepressed.htm' } else { void('') };
">
-
Confirm OK, then popup a new window (uses window.open()) - Confirm, then next web
page - If you press 'OK', then you will launch another web page.
Ex: <a href="javascript: if (confirm('Continue?')) {
window.open('ex_confirm_continuepressed.htm'); void('') } else { void('') };
">
- The normal html would look like:
blnAnswer = confirm('When finished, click OK')