Click here to Skip to main content
12,999,628 members (42,151 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I am calling the confirm("Are you sure you want to delete");
then I get the standard "Ok" and "Cancel" buttons with "Ok" as the default.

Because this is a delete is there a way, other than creating a custom dialog box, the change the default button to be the "Cancel" button? Or even reverse the text of the boxes?

Posted 25-Jan-13 8:08am
Abhishek Pant 25-Jan-13 14:37pm
use modal popup

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Unfortunately, there is no way to influence the appearance and the behavior of the built-in dialog.

So you either make a custom dialog with jquery for example[^], or you change the question formulation to have the godd default button: instead of "Are you sure you want to delete this?" ask "Would you better keep this?" :)
MacIntyre 25-Jan-13 15:45pm
Would this work instead:
$.prompt('Example 4',{ buttons: { Ok: true, Cancel: false }, focus: 1 });
Zoltán Zörgő 25-Jan-13 16:28pm
Give it a try :)
Sergey Alexandrovich Kryukov 25-Jan-13 17:03pm
Actually, jQuery dialogs or modal windows (don't mix them up with those evil pop-ups!) make a lot of sense. It's always better to prefer lightweight components and get rid of build-in alert or confirm. Those dialogs do not belong the page. My 5.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170624.1 | Last Updated 25 Jan 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100