From b9706f23f5dfbcf11f354a6068bbe98ad319990d Mon Sep 17 00:00:00 2001 From: MinRK Date: Mon, 1 Jul 2013 21:49:39 -0700 Subject: [PATCH] use `window.onbeforeunload=` for nav-away warning Firefox 22 broke `$(window).on("beforeunload")` somehow, for some reason, resulting in always showing a dialog, regardless of the function's return value. The only fix I could find was resorting to the basic low-level API. --- IPython/html/static/notebook/js/notebook.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/IPython/html/static/notebook/js/notebook.js b/IPython/html/static/notebook/js/notebook.js index 90fd2868b..42ad4d238 100644 --- a/IPython/html/static/notebook/js/notebook.js +++ b/IPython/html/static/notebook/js/notebook.js @@ -350,8 +350,10 @@ var IPython = (function (IPython) { var time = (extrap != undefined) ? ((extrap.duration != undefined ) ? extrap.duration : 'fast') : 'fast'; expand_time(time); }); - - $(window).bind('beforeunload', function () { + + // Firefox 22 broke $(window).on("beforeunload") + // I'm not sure why or how. + window.onbeforeunload = function (e) { // TODO: Make killing the kernel configurable. var kill_kernel = false; if (kill_kernel) { @@ -370,7 +372,7 @@ var IPython = (function (IPython) { // Null is the *only* return value that will make the browser not // pop up the "don't leave" dialog. return null; - }); + }; }; /**