0

如何阻止以下jquery函数。我测试了不同的脚本和自己的脚本,但注意到工作。

$(document).ready(function () {

  $(window).on('beforeunload', function() {
        return "\
Are you sure you want to leave this page....";
  });
});
#

抱歉,两个脚本都不会停止离开对话框

// ==UserScript==
// @name           Test
// @namespace      
// @description    Disable - remove the annoying onbeforeunload event
// @include        *
// @author         test
// ==/UserScript==

(function() {
      unsafeWindow.onbeforeunload = null;

      unsafeWindow.onunload = null;

      //unsafeWindow.alert = null;

      //unsafeWindow.confirm = null;

      //unsafeWindow.prompt = null;

      //unsafeWindow.open = null;

      //$(window).off('beforeunload'); //don't work
$(window).on('beforeunload',function() {/* override function that does nothing*/});
})();
4

1 回答 1

4

I believe off is what you're looking for:

$(window).off('beforeunload');
于 2013-09-30T19:28:33.793 回答