Javascript 如何在javascript中创建是/否/取消框而不是确定/取消?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3110825/
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
how to create yes/no/cancel box in javascript instead of ok/cancel?
提问by SLaks
How to create a yes/no/cancel alert box instead of ok/cancel alert box in Javascript?
如何在 Javascript 中创建是/否/取消警报框而不是确定/取消警报框?
回答by SLaks
You can't.
你不能。
Instead, you can use a fake dialog library, such as jQuery UI Dialog.
相反,您可以使用假对话框库,例如jQuery UI Dialog。
These libraries create HTML elements that look and behave like a dialog box, allowing you to put anything you want (including form elements or video) in the dialog.
这些库创建的 HTML 元素的外观和行为都类似于对话框,允许您在对话框中放置任何您想要的内容(包括表单元素或视频)。
回答by Evan Trimboli
There's nothing native built in to do this. You could use a framework to simulate it, for example: http://www.sencha.com/deploy/dev/docs/?class=Ext.MessageBox
没有任何内置的东西可以做到这一点。您可以使用框架来模拟它,例如:http: //www.sencha.com/deploy/dev/docs/?class=Ext.MessageBox
回答by Tom Gullen
This will work in IE, but as for other browsers I'm not sure. It's important to note that yes/no/cancel is not officially supported by Javascript so you are better off using ok/cancel wherever possible.
这将在 IE 中工作,但至于其他浏览器,我不确定。需要注意的是,Javascript 并未正式支持 yes/no/cancel,因此您最好尽可能使用 ok/cancel。
<script language=javascript>
/*@cc_on @*/
/*@if (@_win32 && @_jscript_version>=5)
function window.confirm(str)
{
execScript('n = msgbox("'+str+'","4132")', "vbscript");
return(n == 6);
}
@end @*/
var r = confirm("Can you do it?");
alert(r);
</script>

