In IE and FF, i can attach an event handler to onBeforeUnload, and by passing a string to a property of the event, the user will see a dialog asking him whether he wants to
This works perfectly for me in both Chrome and Safari:
Test
When I try to close the window, I get the prompt.