Works on Chrome, if the idea is to prevent the reload/refresh:
window.addEventListener('beforeunload', function(e) { e.preventDefault(); e.returnValue = ''; // For Chrome return ''; });