How to capture event when user is closing the Browser [modified]
-
I have a shopping cart site. I am storing products choosing in the session. How can i help me to capture event when user clicks the Close button (X button on the right top) to exit the Browser. Thank in advance vtkiet05
-
I have a shopping cart site. I am storing products choosing in the session. How can i help me to capture event when user clicks the Close button (X button on the right top) to exit the Browser. Thank in advance vtkiet05
You can use onunload event of javascript. Something like this Good Luck.
-
You can use onunload event of javascript. Something like this Good Luck.
Thank you for reply. Your code will always display message whenever the page closed. That mean user has still not close Browser, they click other items on page the message display too. Actually, I only confirm to user if they clicked Close Button (X buton on the right top ) Thank all your help vtkiet05 -- modified at 0:33 Wednesday 4th July, 2007
-
Thank you for reply. Your code will always display message whenever the page closed. That mean user has still not close Browser, they click other items on page the message display too. Actually, I only confirm to user if they clicked Close Button (X buton on the right top ) Thank all your help vtkiet05 -- modified at 0:33 Wednesday 4th July, 2007
>>Thank for your reply, Could you test the case which you link to other page? >>I think that the message will displays. I don't want to display a message >>this case. I would like to display a message if user clicked Close Button (X >>button on the right top) >>Thank all your helps chk it out. hope it would help..
var UNLOAD_MSG = "You will lose any unsaved changes!"; var IGNORE_UNLOAD = true; function doBeforeUnload() { if(IGNORE_UNLOAD) return; // Let the page unload if(window.event) window.event.returnValue = UNLOAD_MSG; // IE else return UNLOAD_MSG; // FX } if(window.body) window.body.onbeforeunload = doBeforeUnload; // IE else window.onbeforeunload = doBeforeUnload; // FX function CheckOrder(isChanges) { IGNORE_UNLOAD = isChanges; } [mike](http://michaelsync.net)
Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net) If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you. :)