【发布时间】:2017-01-07 20:21:54
【问题描述】:
我希望页面在显示 msgBox 时停止重定向,并等待用户按下框上的按钮。
我可以在页面卸载时显示 msgbox,但页面仍会重定向到另一个网页,而无需等待用户输入。
<script>
$(window).bind('beforeunload', function () {
msgbox();
});
function msgbox() {
$.msgBox({
title: "Confirmation",
content: "Do you agree with the information provided?",
type: "confirm",
buttons: [{ value: "Yes" }, { value: "No" }],
success: function (result) {
if (result == "Yes") {
window.location.replace("somepage/controller/func2");
} else {
window.location.replace("somepage/controller/func1");
}
}
});
}
</script>
【问题讨论】: