Make a question if you change a page
i'm new to starckoverflow.
I'm trying to stop 开发者_JAVA技巧to change the current page. I have an order page, with a lot of field that are updated on line. I would like to make a question if your move to previous page, or if you click any other url, so i can show something like : Attention !!! if you continue you will lost all data already inserted.
So i can erase all data already inserted in db. Is possible to do this ?
I'm working with aspx page in VB Thanks to all Alex
You could use the onbeforeunload javascript event to ask the question...this occurs before the page is unloaded. You would want to set a flag to see if they have entered anything and then prompt them...it will give the option for the user to "cancel" unloading the page and stay on the current page.
Info about the event: https://developer.mozilla.org/en/DOM/window.onbeforeunload
精彩评论