H
H
hollanditkzn2018-03-06 13:30:06
JavaScript
hollanditkzn, 2018-03-06 13:30:06

How to refresh the confirmation page when passing a test?

I have tests, which is a timer and the result is displayed in a modal window. If we use this example, which is said a lot on the Internet,

function Unloader(){
 
    var o = this;
 
    this.unload = function(evt)
    {
        var message = "Вы уверены, что хотите покинуть страницу оформления заказа?";
        if (typeof evt == "undefined") {
            evt = window.event;
        }
        if (evt) {
            evt.returnValue = message;
        }
        return message;
    }
 
    this.resetUnload = function()
    {
        $(window).off('beforeunload', o.unload);
 
         setTimeout(function(){
            $(window).on('beforeunload', o.unload);
        }, 2000);
    }
 
    this.init = function()
    {
         
        $(window).on('beforeunload', o.unload);
 
        $('a').on('click', function(){o.resetUnload});
        $(document).on('submit', 'form', function(){o.resetUnload});
        $(document).on('keydown', function(event){
            if((event.ctrlKey && event.keyCode == 116) || event.keyCode == 116){
                o.resetUnload;
            }
        });
    }
    this.init();
}
 
$(function(){
    if(typeof window.obUnloader != 'object')
    {
        window.obUnloader = new Unloader();
    }
})

Then when I redirect, this confirmation also turns on, but how to avoid this and turned on when he leaves the site that did not pass the test.
If it is not clear then when it is still passing the test in this case so that there is confirmation for updating, and when the test is over and the timer is not ticking, let's say the period has expired answered all the questions, then there was no confirmation for updating the page

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question