On most pages, if you perform an action (such as editing, creating), and when I try to exit, it basically tells me if I really want to exit. The dialog gives me two options: leave or cancel and continue. How do you do this in javascript? Should I use a meta element? And please do not mention beforeunload unless this is the true and only way to accomplish this.
beforeunload
Why not mention onbeforeunload ? This is a built-in way to do this, and I see no problem using it.
onbeforeunload
function myConfirmation() { return 'Are you sure you want to quit?'; } window.onbeforeunload = myConfirmation;
what i use is:
onClick="return confirm('Sure you want to exit..?')"
window.onbeforeunload = function() { if(confirm('are you sure to exit?')) return true; else return false; };
Source: https://habr.com/ru/post/947440/More articles:Porting the Chrome extension to Firefox: equivalent to chrome.storage - javascriptADO speeds up open table access - ms-accessPrevent log4net from creating a new log file after renaming the log file in code - c #Log4Net dynamic file name not working - loggingShould all business logic be in domain models or? - c #Add dynamic div on click - javascriptWord-break: the word break does not work in Firefox 21 - csswhy ++ is overloaded, but not - for C ++ bool - c ++Removing Users in CRM Dynamics 2011 - c #Disabling SSL certificate validation for an Active Directory server using spring -ldap 1.3.1 - javaAll Articles