Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment #1
Crell CreditAttribution: Crell commentedI'm not sure when it was changed, but the latest stable appears to be doing that now.