在 javascript 确认对话框中更改标题和选项

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

Changing title and options in javascript confirm dialog

javascriptdialogconfirm

提问by Mohammad Tausif Razi

I want to add my project title to a javascript confirm dialog, and want to change "Ok" and "Cancel" to "Yes" and "No". How can I do this?

我想将我的项目标题添加到 javascript 确认对话框,并想将“确定”和“取消”更改为“是”和“否”。我怎样才能做到这一点?

回答by

We can't override the functionality of the JS . But you can show your project name on top by using the trick "nextline(/n)" as i did in my project :)

我们不能覆盖 JS 的功能。但是你可以像我在我的项目中那样使用技巧“nextline(/n)”在顶部显示你的项目名称:)

This is just an trail solution for your satisfaction . :)

这只是一个让您满意的线索解决方案。:)

confirm("ProjectName \n\n\n\n\ some question goes here ");

回答by tradyblix

If you're talking about confirmfunction in javascript, well, you can't change its properties. I suggest look into using a custom confirm dialog box e.g. jQuery UI's modal confirmation. You have many options out there and by using custom ones you have a lot of things you can do, you can even change colors of the box if you want. Just an idea :)

如果您在谈论confirmjavascript 中的函数,那么,您无法更改其属性。我建议考虑使用自定义确认对话框,例如 jQuery UI 的模式确认。您有很多选项,通过使用自定义选项,您可以做很多事情,如果需要,您甚至可以更改框的颜色。只是一个想法:)