Code to ask yes/no question in javascript

No.

Instead you could use a in browser modal popup.


Javascript offers 3 modal boxes. prompt, confirm and alert. None of those satisfy your request.

There are a plethora of js modal popup solutions. Here's an example.

  • ModalBox

No, but there are JavaScript libraries that can accomplish this for you. Just as an example, Ext JS can be used to create a message box dialog.


Like everyone else above says, you're stuck with OK/Cancel using confirm().

I would like to recommend this jQuery plugin though: jqModal. I've used it on 3 recent projects and it has worked great for each one. Specifically check out this example:

6). FUN! Overrides -- a. view (alert), b. view (confirm) It is now time to show a real-world use for jqModal -- overriding the standard alert() and confirm dialogs! Note; due to the single threaded nature of javascript, the confirm() function must be passed a callback -- it does NOT return true/false.

Tags:

Javascript