I know how to stop the page navigating away and produce a "Stay on this page" / "Leave the page" message with Javascript. The code I use works fine as below. You can place a custom message in the return statement if you wish.
<script>
window.onbeforeunload = confirmExit;
function confirmExit()
{
return "";
}
</script>
What I would like is a more customizable message such as the one when you hit the back button with an open message in Hotmail / outlook.com. That isn't a standard browser message it seems to create a nice banner across the page. I design using PHP / Javascript but perhaps this is done using ASP?