Dattu
asked on
shpwing alert when closing the browser using right side top 'X' button
Hi,
I need to display a box do you want to continue closing the button and loose all the information when an user click on close X button
I need to display a box do you want to continue closing the button and loose all the information when an user click on close X button
Might not be OK in Firefox, BUT...you can add a method to the "window" object:
window.onbeforeunload = function(msg){
return confirm(msg);
}
NOTE: I have not tested this, and for practical reasons you may want to make sure there is no "onbeforeunload" event in whatever browser you are in BEFORE YOU BLINDLY DO ANYTHING LIKE THIS!
window.onbeforeunload = function(msg){
return confirm(msg);
}
NOTE: I have not tested this, and for practical reasons you may want to make sure there is no "onbeforeunload" event in whatever browser you are in BEFORE YOU BLINDLY DO ANYTHING LIKE THIS!
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Sorry, you only want to do this for NON-IE browsers:
if (!document.all) { // Not of the IE family
if (!window.onbeforeunload) { // Make sure the event is not defined
window.onbeforeunload = function(msg){
return confirm(msg);
}
}
}
if (!document.all) { // Not of the IE family
if (!window.onbeforeunload) { // Make sure the event is not defined
window.onbeforeunload = function(msg){
return confirm(msg);
}
}
}
>>is the same result of putting il on the body tag......
No, it is not. My example clearly and cleanly removes JavaScript from the HTML code. Further, multiple events can be invoked easily.
The French call it "mise en place", and it means "everything is where they are supposed to be".
No, it is not. My example clearly and cleanly removes JavaScript from the HTML code. Further, multiple events can be invoked easily.
The French call it "mise en place", and it means "everything is where they are supposed to be".
(or something like that ;-)
<body onBeforeUnload="return 'Quit and lost all data?'">