我正在使用swal警报框,当用户单击“确定”按钮时,只需要关闭当前选项卡即可。
$(document).ready(function(){
swal({
title: "Are you sure ??",
text: 'hii',
icon: "success",
buttons: true,
//dangerMode: true,
})
.then((willDelete) => {
if (willDelete) {
window.close();
} else {
window.close();
}
});
});
答案 0 :(得分:0)
使用来自Docs的自定义确认对话框 您可以在下面使用以下代码:
Swal.fire({
title: "Error",
text: "wrong user or password",
type: "error",
showCancelButton: false,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'OK'
}).then((result) => {
if (result.value) {
window.close();
}
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@8"></script>