is it possible to add a confirmation when user click on the 'X' button on the browser toolbar?
How to do this?
| SitePoint Sponsor |

is it possible to add a confirmation when user click on the 'X' button on the browser toolbar?
How to do this?



I do not believe that you can access those sort of low-level browser events sorry. You can use the onUnload event but that does not take in to account "how" the browser exits the page.
Regards,
Jordan
This is possible in some browsers. Use the onbeforeunload event.
We miss you, Dan Schulz.
Learn CSS. | X/HTML Validator | CSS validator
Dynamic Site Solutions
Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.

ok, i'll try out!
thank you! =)



I did not think this would allow you to capture the 'X' button click in the browser itself? How can you detect between hitting the 'X', and going 'File' -> 'Close'?Originally Posted by Kravvitz
What would be the benefit of calling the BeforeOnUnload over OnUnload?
Regards,
Jordan
It doesn't detect the close button. It detects if the page is unloading. It doesn't matter if the tab/window is being closed or the user is navigating to another page.
You can't stop the tab/window from closing via onunload.
We miss you, Dan Schulz.
Learn CSS. | X/HTML Validator | CSS validator
Dynamic Site Solutions
Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.
Bookmarks