0

Im preparing an online quiz , and prevent that from unloading by onbeforeunload js object , after the time will up , I want to redirect the page to report page , but I cant cancel onbeforeunload event ! is anyone knows a trick for it ?

var isPostback = false;
window.onbeforeunload = unloading;
function unloading() {
  if (!isPostback) {
    return 'Caution: The timer will not be paused.';
  }
}

I want to cancel above event after the time's up

4

1 回答 1

4

在计时器的回调中,您可以设置window.onbeforeunload = null删除处理程序。

于 2013-11-14T20:22:01.847 回答