Thursday, October 22, 2009

How to have alert message on a window close if pressing ok close the window else return to window (w

I am using this code but it only works for IE but i need it for opera, safari ,firefox etc also.



function HandleOnClose(event) {



if (event.clientY %26lt; 0) {



event.returnValue = %26#039;Are you sure you want to leave the page?%26#039;;



}



}



How to have alert message on a window close if pressing ok close the window else return to window (web page)?





x = confirm(%26#039;Close window?%26#039;);



if(x) {



window.close();



}



confirm returns true if OK is pressed, and false if Cancel is pressed so you could just use that.



Just out of interest, can you show us how your function is being called - maybe there%26#039;s another way.

No comments:

Post a Comment

Blog Archive