Click here to Skip to main content
15,892,575 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have one master page,sidebar with sub menus.each submenus has one page, using that master page.while navigating one menu to another i displayed popup "are you want to leave from this page".

But this pop need to work only if the sub menu pages have some text in textboxes(like we entered some details suddenly move to another page (menu)).textboxes are in sub menu pages.

please post jquery and say where i have to use the jquey(master page or sub menu page)

What I have tried:

Used this in master page.


JavaScript
<script type="text/javascript" language="javascript">
        window.onbeforeunload = function() {
            var Ans = confirm("Are you sure you want change page!");
            if (Ans == true)
                return true;
            else
                return false;
        };
    </script>
Posted
Updated 2-May-17 20:50pm

1 solution

You can check first if there is some change occurred in page or not then go for confirmation.

example:-
var somethingChanged = false;
$(document).ready(function() { 
   $('input').change(function() { 
        somethingChanged = true; 
   }); 
});
 
Share this answer
 
Comments
GrpSMK 3-May-17 2:55am    
where i have to use this masterpage?
Member 12346239 4-May-17 5:46am    
yes

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