javascript - Intercept selection in window.onbeforeunload dialog -
in web application if user leaves current page without having saved changes in form pop window opened alert him that.
for pop use scripts code injected codebehind (c#):
var confirm = true; window.onbeforeunload = confirmclose; function confirmclose() { if (!confirm) return; if(/*check change condition true*/) { return " + warn_message + "; } }
i need intercept whether user click on cancel or ok button.
i tried like:
var button_pressed = window.onbeforeunload = confirmclose;
but returns true.
how can button pressed? thanks
not possible. there no event associated buttons. might able see if user came setting value or perhaps cookie in page in onbeforeunload , test if there after time has passed
but see duplicate way know if user clicked cancel on javascript onbeforeunload dialog?
Comments
Post a Comment