Possible Duplicate:
Javascript close alert box
A confirm box can be opened by,
confirm("Sure?");
which opens a confirm pop up with two buttons- OK and Cancel.
The pop up closes when either of the two buttons are clicked. How can we close the pop up without clicking the buttons, pragmatically? Can we trigger the event which closes the pop up using JavaScript?
Short answer: No.
Long answer: The three
DOM0windows ofalert,confirmandpromptare modal windows. The browser (or the browser window, depending) freezes when those using one of those input methods and nothing Javascript-wise happens.The only thing you can do is to create a popup
DIVwith your own confirm buttons and give your popup window callback methods on what to do onconfirmacceptandcancel.A
setTimeoutcould be used to auto-close the window after a pause.