Answer the question
In order to leave comments, you need to log in
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();
}
})
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question