Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
188
rated 0 times [  194] [ 6]  / answers: 1 / hits: 25188  / 11 Years ago, mon, june 17, 2013, 12:00:00

In most pages, if your doing an action, (like editing, creating), and when I attempt to exit, it mostly prompts me if I really want to exit. The dialog gives me two options: leave or cancel and continue. How do you accomplish this in JavaScript? Do I have to use a meta element? And please don't mention beforeunload, unless it's the true and only way to accomplish this.


More From » html

 Answers
214

Why not mention onbeforeunload? It's the built in way to do so, and I don't see a problem using it.



function myConfirmation() {
return 'Are you sure you want to quit?';
}

window.onbeforeunload = myConfirmation;

[#77595] Friday, June 14, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
eden

Total Points: 730
Total Questions: 117
Total Answers: 117

Location: Peru
Member since Fri, Oct 14, 2022
2 Years ago
;