This is the code for preventing page refresh/close tab, when clicking cancel button in dialog box local storage values are clearing. how to retain local storage values ?
window.addEventListner('beforeunload', function(e) {
e.preventDefault();
e.returnValue = '';
})