Within my Laravel project, I need to give a warning message, when browser close button click event or browser's tab button close event.
When only (ctrl+shift+R) refresh the browser, 'Changes you made may not be saved.' default message will display. Otherwise nothing.
<script type="text/javascript">
window.addEventListener('beforeunload', function (e)
{
// Cancel the event
e.preventDefault();
console.log(e);
// Chrome requires returnValue to be set
e.returnValue = 'Are you sure?';
});
</script>
This warning return when reload the page '[Violation] Added non-passive event listener to a scroll-blocking 'touchstart' event. Consider marking event handler as 'passive' to make the page more responsive. See https://www.chromestatus.com/feature/5745543795965952'
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire