gpt4 book ai didi

javascript - BootstrapDialog打开后如何防止脚本执行?

转载 作者:行者123 更新时间:2023-11-29 14:47:40 25 4
gpt4 key购买 nike

我正在使用 BootstrapDialog 来显示一些警报。

    BootstrapDialog.alert({
type: BootstrapDialog.TYPE_DANGER,
title: 'Oops! ',
message: 'Error, occured',
buttons: [{
label: 'Ok'

}]
});
window.location.replace("http://example.com");

我希望如果对话框打开它不会重定向到另一个页面。它应该只在用户单击“确定”按钮时重定向,就好像我在 javascript 中使用警报一样。

最佳答案

您应该在 buttons 属性中附加 window.location 代码。尝试这样做:

BootstrapDialog.show({
type: BootstrapDialog.TYPE_DANGER,
title: 'Oops! ',
message: 'Error, occured',
buttons: [{
label: 'Ok',
action: function(dialog) {
window.location.replace("http://example.com");
}
}]
});

关于javascript - BootstrapDialog打开后如何防止脚本执行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30704983/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com