Click here to Skip to main content
15,610,223 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
In my application, I have a menu in master page. The application asks for confirmation if the user is working on a Page and navigates to other screen/page without saving. It should show confirm msg like 'Do you want to leave this page without saving?' Are there any possiblities to do this?
Updated 31-Mar-22 10:17am

Try this:
<script type="text/javascript">
  window.onbeforeunload = confirmExit;
  function confirmExit()
    return "Do you want to leave this page without saving?";
Share this answer
Use this

<script type="text/javascript" language="javascript">
               window.onbeforeunload = function() {
                   var Ans = confirm("Are you sure you want change page!");
                       return true;
                       return false;
Share this answer
GrpSMK 3-May-17 2:35am    
how to display this pop up only while textbox(in menu page) containing some text..and suddenly navigate pages.
You can do this jquery. This is the perfect example you can refer for your query.[^]

If you want to do this on button click event you can refer this.[^]
Share this answer
window.onbeforeunload = function() {
            return 'Are you sure you want to leave this page?';
Share this answer
Richard Deeming 27-Feb-18 11:59am    
As posted in solution #3 - FOUR YEARS AGO.
Member 14705531 9-Feb-20 13:34pm    

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900