Let's say I have an app with a basic tab/window 'stack'. I click something, the window slides in from the right. This window has the default <back button on it.
I know I can listen for the 'blur' event on the new window, to tell when the window is (probably) closing. (I say probably, because an alert or the like will trigger blur too)
But how can I trap the back button being closed (or swipe right on the window) in order to alert the user "Hey! You did things on this window without saving it. It could have been by accident! Are you sure you want to close this window?" - then close the window or not.
It's possible I'm missing something obvious. On a web page I would do it in the window.onbeforeunload event.
Any ideas?
thanks.