Friday, May 31, 2013

How to show message on browser close?

//fully testted

<script type="text/javascript">

window.onbeforeunload = function(){ return 'Are you sure?' };

</script>

// You can also test  ........

<script type="text/javascript">

function confirmClose() {

if (window.event.clientY < 0) {

event.returnValue = "Are you sure do you want to navigate away from this page";

// alert("are you sure ?");



}

}



</script>

<script type="text/javascript">

function quit(){

event.returnValue="Are you sure you have finished?"



}
 
</script>

<body onbeforeunload="quit()">

<script language="javascript" type="text/javascript">

var message='Browser close attempt is detected';

function ConfirmClose()



{
 
debugger;

if (event.clientY < 0)



{
 
event.returnValue = message;



}

}
 
</script>

</head>

<body onbeforeunload="ConfirmClose()">



 <script type="text/javascript">

window.onbeforeunload = function(){ return 'Are you sure?' };

</script>

window.onbeforeunload = function(){ myUnloadEvent(); }

function myUnloadEvent() {

alert ('Calling some alert messages here');

//even you can call some functions that will terminater the DB connections or something similar.



}
 
</script>

1 comment:


  1. Send Mail By Sql..

    USE msdb
    GO
    EXEC sp_send_dbmail @profile_name='PinalProfile',
    @recipients='test@Example.com',
    @subject='Test message',
    @body='This is the body of the test message.
    Congrates Database Mail Received By you Successfully.'

    ReplyDelete