Click here to Skip to main content
15,918,668 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Good Day

I want to show warning message user is about to leave the page by typing url in browser
i wrote this code this only work fine safari and firefox

For chrome and IE it works fine only when t=i erite proper url in the browser eg www.youtube.com.
i write anyting like eg. wewewwww and presss enter it does work properly in chrome and IE

C#
window.onbeforeunload = function (e) {

            /* Getting flag value for Browser if it has been set to true or not */


                /*if true show warning message*/


                    var evtobj = window.event ? event : e;
                    if (evtobj == e) {
                        if (!evtobj.clientY) {
                            return "You have not saved your data. Do you really want to leave this page?";
                        }
                    }


        }
Posted
Comments
Dennis E White 10-Sep-14 14:29pm    
are they leaving the page based on a POST or GET??
surajemo 12-Sep-14 9:35am    
no by typing a new url in the browser or by typing just a random alphabets and pressing enter key

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