如何在 Javascript 中向用户显示是/否消息框?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5271002/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-23 16:25:28  来源:igfitidea点击:

How can I display a yes/no message box to the user in Javascript?

javascriptjqueryasp.net

提问by Sheikh Rahat Ali

How can I display a yes/no message box to the user on the client-side in Javascript?

如何在 Javascript 的客户端向用户显示是/否消息框?

I don't want to display “OK” and “Cancel” to the user, which is the default behavior of the confirmfunction in Javascript. Any help will be appreciated.

我不想向用户显示“确定”和“取消”,这是confirmJavascript 中函数的默认行为。任何帮助将不胜感激。

回答by Town

You can't amend the Ok/Cancel of the default confirm box, but you can use a 3rd party library (such as jQuery/jQuery UI) which will give you what you need: http://jqueryui.com/demos/dialog/#modal-confirmation

您不能修改默认确认框的确定/取消,但您可以使用第 3 方库(例如 jQuery/jQuery UI),它会为您提供所需的内容:http: //jqueryui.com/demos/dialog /#modal-确认

回答by Muhammad Akhtar

回答by mplungjan

回答by Walter Soto

I just posted in my blog an easy to use Yes/No message box that you can easily modify to fit your project.

我刚刚在我的博客中发布了一个易于使用的“是/否”消息框,您可以轻松修改它以适合您的项目。

Example:

例子:

SmallJS.message.modal('Do you want to click yes?', {
                buttons: {
                    ok: 'Yes',
                    cancel:'No'
                },
                onOK: function () {
                    SmallJS.message.show('Yes sir!', { animate:false});
                }
            })

You can see the source code at: http://www.waltersoto.com/javascript/javascript-yes-no-message-box

您可以在以下位置查看源代码:http: //www.waltersoto.com/javascript/javascript-yes-no-message-box