UNPKG

withfront

Version:

Tools for frontend development especially with Bootstrap 3.x and jQuery 3.x also FontAwesome, jsCookie and more

48 lines 1.99 kB
/* * * * * * * * * * * * * * Start * * Window on buffer onload * * * * * * * * * * * * */ // Message to be displayed on unload // var message = $('#jtrnslt #leavemess').text(), submitting = false; // // On Form submition set submitting to true for not fire onbeforeunload // $(document).on("submit", "form", function(event){ // submitting = true; // }); // // Window onbeforeunload fired when leave page but not if it a form submition or element with .noBeforeUnload class // window.onbeforeunload = function (e) { // e = e || window.event; // // Determine if you want to allow unload // /* some synchronous operation here*/ // if (!submitting && !$(e.target.activeElement).hasClass('noBeforeUnload')) { // // IE BUG: throws unspecified error on "cancel" // // so we temporarily mask all Javascript errors // window.onerror = function (msg, url, linenumber) { // return -1 < msg.toLowerCase().indexOf('unspecified error'); // }; // // After return the (blocking) confirmation window is shown // // after which we remove Javascript error handler // window.setTimeout(function () { // window.onerror = function () { // return false; // } // }, 100); // // -- IE BUG // // // default message if missed // if (message.length == 0) { // message = 'Are you sure you want leave this page without save? Sei sicuro di volere uscire senza salvare?'; // } // // // IE expects the confirmation string in the // // `returnValue` property of event object // if (e) { // e.returnValue = message; // } // // Other browsers expect it returned as a string // return message; // } // }; /* * * * * * * * * * * * * * END * * Window on buffer onload * * * * * * * * * * * * */