javascript 警报框中是否可以使用自定义按钮?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5046754/
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
Are custom buttons possible in an alert box?
提问by Hyman
Hi I have been looking to create custom buttons in an alert box I would like them to say Go and Cancel instead of OK and cancel
嗨,我一直在寻找在警报框中创建自定义按钮,我希望他们说“开始”和“取消”而不是“确定”和“取消”
onClick="if(confirm('Would you like to continue?'))
回答by u476945
No, there is no cross-browser support for opening a confirmation dialog that is not the default OK/Cancel pair, but you can build them with JavaScript such as jQuery Alert Dialogs, jQuery impromptu, Mootools LightFaceand many more.
不,没有跨浏览器支持打开不是默认的 OK/Cancel 对的确认对话框,但您可以使用 JavaScript 构建它们,例如jQuery Alert Dialogs、jQuery impromptu、Mootools LightFace等等。
回答by Eineki
You can't, as far I know. The button caption are not customizable by design.
你不能,据我所知。按钮标题不可按设计自定义。
It is needed to avoid possible fraud (think what can happen if you switch the caption of confirm and cancel buttons).
需要避免可能的欺诈(想想如果您切换确认和取消按钮的标题会发生什么)。

