1

I need to fire some functionality from javascript when a user has finished editing a page and saves it or leaves the editing mode.

Is there a possibility to catch the event?

1

Use window.onbeforeunload in edit mode to perform all your operations. Here is how you check edit/display mode

    window.onbeforeunload = function (e) {
    var message = "Your confirmation message goes here.",
     e = e || window.event;
     // For IE and Firefox
     if (e) {
        e.returnValue = message;
     }

      // For Safari
      return message;
};
  • Can I determine from the returnValue if the site was really saved on the server? Because as I understand, this event is always fired when user leaves edit mode, regardless if he saved the site or discarded check out. – Florian Leitgeb Jun 19 '15 at 10:12
  • Unfortunately it is also not possible to gather user information in the on onbeforeunload, because you can not fire alerts or confirm messages. – Florian Leitgeb Jun 24 '15 at 12:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.