I want the page to stop from redirecting when the msgBox is displayed and wait untill user has pressed a button on the box.
I am able to display the msgbox when the page unloads, but still the page redirects to another webpage without waiting for user's input.
<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>