Hi!, thanks for sharing this module. Unfortunately, the $(window).unload event can't prevent the user from navigating away, it gets executed right before the page is being unloaded and before showing the new page.

You could do something like:

window.onbeforeunload = function() {
     var clicked = $window.attr('node_edit_protection_clicked');
     var edited  = $window.attr('node_edit_protection_edited');
     
     if (edited && !clicked) {
       return Drupal.t("You are about to leave a form that may contain changes that will not be saved.");
     }
   };

And this would work (on most browsers) as desired.

Comments

Crell’s picture

Status: Active » Fixed

I'm not sure when it was changed, but the latest stable appears to be doing that now.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.