I Want to prompt a message when leaving the page without unsaved changes. and also want to alert when changes made and directly want to access another page.
Asked
Active
Viewed 643 times
-1
-
@CodeCaster Aren't the technologies used in that question & in this question different? – RAS Aug 19 '13 at 12:35
-
@RAS op does not show at all what he wants to accomplish and what has been tried. A solution to prevent tab closure is given in linked question. If OP has more questions, he should update the question. – CodeCaster Aug 19 '13 at 12:37
2 Answers
2
You can use it with a Javscript function:-
function func(){
return 'Your message'
}
window.onbeforeunload = func
You can also check out this Thread

Community
- 1
- 1

Rahul Tripathi
- 168,305
- 31
- 280
- 331
1
Keep a boolean dirty that is set to true whenever the user makes a change. Then if it's true when the user tries to leave you display your warning. After each save action you set dirty to false and false is the default value.
This will always be brittle, so it's better to just save every change.

MrFox
- 4,852
- 7
- 45
- 81