Click here to Skip to main content
15,906,947 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am making a page where different users have to login to use their portal... here, i have created a form where user enters data,, as user opens the form, the record is created in database and user input is updated in database.. now what i wanted is when user clicks on save, then only record that is updated is stored.. if user clicks on exit or close button of browser or other button or any other control except save, the message should appear like "Are you sure you want to leave page" and if user clicks on yes, the record is to be deleted... how can i create such control that asks user a permission if they want to quit or continue and then delete a record is yes is selected???
Is it that it can be done by javascript?? or i need to use other tools??
Posted

Try like this

XML
<script type="text/javascript">

        function something()
        {
            //your code
            return false;
        }

        window.onbeforeunload = function () {
            var flag = something();
            if (flag) {

                return 'Are you sure you want to exit without saving ?';
            }

        };

    </script>


check this How to detect browser close when browser [X] is clicked ?[^]
 
Share this answer
 
v2
thanks for the link karthik...
 
Share this answer
 

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