setty
setty

Reputation: 215

How to interrupt page unload from javascript without confirm or return

Problemm is: I have form that has changed data in it and on onbeforeunload event i bind form validation and warning message about unsaved data. Erlier i've used return/confirm function, so user has seen browser modal window with two buttons Ok and Cancel. As this case difficult to test I decided to do over confirm process whithout using those two functions.

How can I interrupt page unload inside onbeforeunload event without using confirm/return functions.

Upvotes: 1

Views: 902

Answers (1)

Tom Tu
Tom Tu

Reputation: 9593

There is no other way to prevent page unload other then using onbeforeunload event - if there was google would probably have used it in gmail - but they didn't.

If you'd try to do it with unload event you can at best force the user to stay on the same page - page will reload though and most likely you'll loose all your data.

Upvotes: 1

Related Questions