0
msgBox가 표시 될 때 페이지 리디렉션이 중단되고 사용자가 상자의 버튼을 누를 때까지 기다리십시오.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>
하지만 이제는 "변경 사항이 저장되지 않을 수 있습니다"라는 경고와 함께 휴가 및 체류 옵션이 표시됩니다. 클릭하면 머스트 박스가 나타납니다. –
@SahibUzZaman 'beforeunload'이벤트에서는 피할 수 없습니다. 보안상의 이유로 기본값이 있습니다. 자세한 내용은 [SO 대답] (http://stackoverflow.com/a/32018719/2588459)을 확인하십시오. – harkirat1892