View Full Version : How can i make a msgbox appear when the user closes the program.

D34th Maker
01-07-2012, 05:29 AM
Hey codingforums members im wondering what would be the code to have a msgbox appear when the user closes the program and have it close after 3 seconds to 7 seconds.

If you need my current code just say and ill add it in to this topic.

01-07-2012, 10:53 AM
How exactly would they be closing the program? A tab close-out? If so:

<script type="text/javascript">
farewell = function() {
alert("Thank you for using this program!");

^Put this in your <head> tag.

After that, add this into your HTML body tag:

<body onunload="farewell()">

Javascript is likely the best solution for this feature, although we could use a few more details about what you want to do. Forcing somebody to stare at the goodbye message for 3-7 seconds before the tab closes isn't a good idea in my opinion - a simple goodbye popup that can be Xed out of would work better if you ask me.