Muh*_*tar 109 html javascript confirm popup button
Javascript确认弹出窗口,我想显示是,否按钮而不是确定和取消.
我使用过这个vbscript代码:
<script language="javascript">
function window.confirm(str) {
execScript('n = msgbox("' + str + '","4132")', "vbscript");
return (n == 6);
}
</script>
Run Code Online (Sandbox Code Playgroud)
这只适用于IE,在FF和Chrome中,它不起作用.
有什么工作要在Javascript中实现这一点吗?
我也想改变像IE浏览器'Windows Internet Explorer'中弹出的标题,我想在这里显示我自己的应用程序名称.
joh*_*vey 87
遗憾的是,没有跨浏览器支持打开不是默认确定/取消对的确认对话框.您提供的解决方案使用VBScript,它仅在IE中可用.
我建议使用一个可以构建基于DOM的对话框的Javascript库.试试Jquery UI:http://jqueryui.com/
您也可以使用http://projectshadowlight.org/jquery-easy-confirm-dialog/.它非常简单易用.只需包含jquery公共库和另外一个文件:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js"></script>
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.1/themes/blitzer/jquery-ui.css" type="text/css" />
<script src="jquery.easy-confirm-dialog.js"></script>
Run Code Online (Sandbox Code Playgroud)
你可以使用sweetalert。
导入到您的 HTML 中:
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@8"></script>
Run Code Online (Sandbox Code Playgroud)
并触发警报:
Swal.fire({
title: 'Do you want to do this?',
text: "You won't be able to revert this!",
type: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Yes, Do this!',
cancelButtonText: 'No'
}).then((result) => {
if (result.value) {
Swal.fire(
'Done!',
'This has been done.',
'success'
)
}
})
Run Code Online (Sandbox Code Playgroud)
欲了解更多数据,请访问sweetalert 警报网站
非常容易使用:
bootbox.confirm("Are you sure?", function(result) {
Example.show("Confirm result: "+result);
});
Run Code Online (Sandbox Code Playgroud)