[thelist] JavaScript - confirm() with more than two options

James Aylard evolt at pixelwright.com
Tue May 14 15:07:01 CDT 2002


Bill,

> Is this possible? Could I somehow trigger a confirm() dialog with
JavaScript
> that offers three different options, like Yes/No/Maybe instead of just
> OK/Cancel?

    Strictly speaking, no, it isn't possible. But, depending on your target
audience, there are some ways to mimic this:

1) IE 3+-only: use VBScript's MsgBox function
2) IE 4+-only: open a modal dialog (window.showModalDialog()), and create a
simple page that includes the 3 buttons (but going with option 1) would be
easier)
3) Cross-browser: open a new browser window sans toolbars, etc., create a
simple web page that contains the three buttons that you want, and hope
nobody notices that the "dialog box" can't maintain focus (yes, there are
tricks using Javascript that can help maintain focus, but these aren't
foolproof and can be annoying)
4) NS 4+, IE 4+: use a positioned div that contains three buttons and style
it to appear like a dialog box. But you'll have a hard time keeping anyone
from clicking anywhere else on the page while the "dialog box" is open.

    Those are the options that I can think of ottomh.

James Aylard




More information about the thelist mailing list