jquery settings disable browser refresh

code show as below:

$(document).bind("keydown", function (e) { // Document binding keyboard down event 
    e = window.event || e; // Solve browser compatibility issues    
    if (e.keyCode == 116 ) { // Press F5 
        var delIsHidden = $("#delete_pop").is(":hidden" );
         var notSaveIsHidden = $("#not_save_pop").is(":hidden" );
         // Display popup Now , disable F5 to refresh 
        if (delIsHidden == false || notSaveIsHidden == false ) {
            e.keyCode = 0;
            return false;
        } else { // Let refresh and delete the session of the large screen 
            sessionStorage.removeItem("five screen" );
        }
    }
});

Notice:

  1. The purpose of this is to prohibit users from refreshing the browser through F5 if the content of the web page is not loaded. This method is not very good and should not restrict users too much.
  2. For old browsers, there is no need to be compatible with it , and it should be eliminated. (except specific users)

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325072300&siteId=291194637