开发者

confirmation modal dialog in javascript

开发者 https://www.devze.com 2023-01-05 17:57 出处:网络
Is it 开发者_StackOverflow社区possible to get confirmation dialog with yes , no option instead of ok,cancel in javascript ?Not using the native browser functions, no.

Is it 开发者_StackOverflow社区possible to get confirmation dialog with yes , no option instead of ok,cancel in javascript ?


Not using the native browser functions, no.

You would have to use a custom dialog class like jQuery dialog.


The default confirmation box is baked into browsers. But you can make use of modal dialogs with the little help of plugins like jQuery UI Dialog or BlockUI.


Not with the native confirm function. You would have to use a custom dialog. Fortunately, there are a lot of good ones available, check out jQuery and it's plug-ins.


$('<div></div>').appendTo('body')
                    .html('<div><h6>Are you sure?</h6></div>')
                    .dialog({
                        modal: true, title: 'Delete message', zIndex: 10000, autoOpen: true,
                        width: 'auto', resizable: false,
                        buttons: {
                            Yes: function () {
                                // $(obj).removeAttr('onclick');                                
                                // $(obj).parents('.Parent').remove();

                                $(this).dialog("close");
                            },
                            No: function () {
                                $(this).dialog("close");
                            }
                        },
                        close: function (event, ui) {
                            $(this).remove();
                        }
                    });

for Demo :

0

精彩评论

暂无评论...
验证码 换一张
取 消