Quackit Logo
HTML
CSS
Scripting
Database
Hosting
Design
XML

Print Version

JavaScript Confirm

The JavaScript confirm box gives your users a chance to confirm an action before JavaScript runs it. The 'confirm' box is created using JavaScript's built-in confirm() function. When the JavaScript confirm() function is triggered, a small box will pop up and display an "OK" button and a "Cancel" button (along with text that you specify in your JavaScript code).

Creating/Triggering a JavaScript Confirm

As mentioned, you create a JavaScript confirm box by calling the built-in JavaScript confirm() function. All you need to do is pass your message to this function.

Basic JavaScript Confirm

You can place the JavaScript confirm() function straight into an HTML tag. Like this:

JavaScript 'confirm()' Within Another Function

The above example works, but it doesn't really do much. You could make your website more useful by including the confirm() function within another function.

Here's an example:

Visit one of these excellent websites:

Enjoy this website?

  • Share
  • Add this page to your Favorites
  • Link to this page (copy/paste into your own website or blog):
  • Link to Quackit using one of these banner ads.
  • Help support Quackit by making a donation

Oh, and thank you for supporting Quackit!

© Copyright 2000 - 2010 Quackit.com