自定义 JavaScript 确认对话框?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17627468/
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-10-27 09:00:38  来源:igfitidea点击:

Customizing JavaScript confirmation dialog boxes?

javascriptjquery

提问by Madhawa Ratnayake

$('#confirm_event').click(function(e){
    var x = $('#function_name').val();
    return confirm('Are you sure you want to submit: ')
})

enter image description here

在此处输入图片说明

While this generates the above, I'd like to replace "title bar text" and include var x value in the return confirm message. I tried several ways but returns undefined value or doesn't work at all. How do I customize the dialog box?

虽然这会生成上述内容,但我想替换“标题栏文本”并在返回确认消息中包含 var x 值。我尝试了几种方法,但返回未定义的值或根本不起作用。如何自定义对话框?

回答by Suresh Atta

You cannot change the default dialog's title. Go for any Jquery Ui dialog plugin.

您无法更改默认对话框的标题。寻找任何Jquery Ui 对话框插件。

Or some other third party dialog plugins.

或其他一些第三方对话框插件。

Prefer to read :Changing the default title of confirm() in JavaScript?

更喜欢阅读:在 JavaScript 中更改 confirm() 的默认标题?

I prefer to use Jquery Ui dialog :)

我更喜欢使用 Jquery Ui 对话框 :)

回答by Dipesh Parmar

Well You can not change look of the window's default alert here what you can do.

那么你不能在这里改变窗口默认警报的外观你可以做什么。

Use jAlert jQuery Pluginthat will let user see custom alert box.

使用jAlert jQuery Plugin它将让用户看到自定义警报框。

Also Take a Look

Take a Look