Imagine that when you're writing articles, then open another tab to relax. After a while you forget about it, and close the browser, so, your article is zero. This code will cause a warning modal to appear in the browser if you refresh, close the tab... before posting. It looks like this:
Make sure Javascript code management is enabled then Create a new javascript.
Title * : Show warning when the browser is closed
Placement : In all the pages
Javascript Code * :
You can translate this text:
Installation
Go to ACP >> Modules >> HTML & JAVASCRIPT >> Javascript codes managementMake sure Javascript code management is enabled then Create a new javascript.
Title * : Show warning when the browser is closed
Placement : In all the pages
Javascript Code * :
- Code:
/* Show warning when the browser is closed - by Zzbaivong */
$(function() {
  $(function() {
    if ($.sceditor) {
      var $win = $(window),
        $editor = $("#text_editor_textarea").sceditor("instance"),
        firstVal = $editor.val();
      $win.on("beforeunload", function() {
        if ($editor.val() !== firstVal) return "Your post may not be saved.";
      });
      $("form[name='post']").on("submit", function() {
        $win.off("beforeunload");
      });
    }
  });
});
You can translate this text:
- Code:
Your post may not be saved.
Last edited by Zzbaivong on July 3rd 2015, 5:21 am; edited 1 time in total