How to display a message when user is closing the Browser
-
I have a code: 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; }
The code above will confirm user whenever they try to exit a page if value of GetStatus() function is 'false'. Actually problem the user has still not exit browser, they link to other pages in the website but they always receive the message "You will lose any unsaved changes!". So I only want display a message when user is closing the Browser (Click "X" button). Thank in advance.
vtkiet05
-
I have a code: 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; }
The code above will confirm user whenever they try to exit a page if value of GetStatus() function is 'false'. Actually problem the user has still not exit browser, they link to other pages in the website but they always receive the message "You will lose any unsaved changes!". So I only want display a message when user is closing the Browser (Click "X" button). Thank in advance.
vtkiet05
I dont think it can be done like that .. all you can do is that you may need to set the statas "IGNORE_UNLOAD" to true manually in each and every click event of "A" tags.
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. :)
-
I dont think it can be done like that .. all you can do is that you may need to set the statas "IGNORE_UNLOAD" to true manually in each and every click event of "A" tags.
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. :)
Thanks Michael for your reply. My exactly problem here is that I can't catch exactly the event when I click X button to close a browser. I tried to use unload event, but the big issue happened. Closing a browser and linking to other page are unload event, so the message always displays when i do both actions. I really want to catch the closing browser event(click on X button) only. Please send me any your solutions. Thanks for all help. vtkiet05
-
Thanks Michael for your reply. My exactly problem here is that I can't catch exactly the event when I click X button to close a browser. I tried to use unload event, but the big issue happened. Closing a browser and linking to other page are unload event, so the message always displays when i do both actions. I really want to catch the closing browser event(click on X button) only. Please send me any your solutions. Thanks for all help. vtkiet05
try "onunload" event of body.. I hav tested ur sample. it shows the msg when i click "x" button of your browser..
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. :)
-
try "onunload" event of body.. I hav tested ur sample. it shows the msg when i click "x" button of your browser..
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. :)
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 vtkiet05
-
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 vtkiet05
vtkiet05@hotmail.com wrote:
I don't want to display a message this case. I would like to display a message if user clicked Close Button
What do you want to do ? Display confirmation message when user closing browser window ?
Navaneeth My Website | Ask smart questions
-
vtkiet05@hotmail.com wrote:
I don't want to display a message this case. I would like to display a message if user clicked Close Button
What do you want to do ? Display confirmation message when user closing browser window ?
Navaneeth My Website | Ask smart questions
Yes, Can you help me do that? I can display confirmation message when user closing browser window now. But if i link to other page, the message also displays. Could you help me display confirmation message when user closing browser window? Thank in advance vtkiet05
-
Yes, Can you help me do that? I can display confirmation message when user closing browser window now. But if i link to other page, the message also displays. Could you help me display confirmation message when user closing browser window? Thank in advance vtkiet05
>>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. :) 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. :) -
>>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. :) 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. :)Very good. Thank you very much!!! vtkiet05