unfortunately, there is no way to override the default behaviour. Most browsers will just display the returnValue of the event, accompanied by an 'OK'/'Leave page' and 'Cancel' button. You can set that message though:
window.onbeforeunload = function (e) {
var e = e || window.event;
// For IE and Firefox prior to version 4
if (e) {
e.returnValue = 'Hey, you are leaving. Do you want to continue?';
}
//you can do some last minute scripting here
// For Safari
return 'Hey, you are leaving. Do you want to continue?';
};
As suggested by Jason P, read more on it here