You can override the getOnUnloadMessage method on the ObjectEditDetailsPage class. Or you may first subclass the page class, see how to specialize a page.