Closing the explorer window.

Posted on 2003-03-13
Medium Priority
Last Modified: 2010-04-01
i am new in jsp. In JSP i want to handle the event of closing the window.for e.x i want that when web page is going to closed by clicking the close button at the top of window or exiting the browser window from anywhere else like by pressing ctrl+alt+delete and select end task , i want to handle closing of explorer window event in jsp.
in VB there are procedure for event close like form_unload(),the same thing i want to implement in jsp.
by doing this i am doing update database according to the user status and updation must take place when the explorer window is closed.
Question by:manu2020
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Expert Comment

ID: 8134589
You can use javaScript for that:

<a href="javascript: self.close()">Close window</a>

Author Comment

ID: 8134626
hello thanassis, i am not getting u. i want that when user clicks the close button(not in my page but at the top of explorer window,close button is usually with minimize and maximize button). i do not require hyperlink for it.
      when explorer window gets closed then automatically some updation in database takes place.

Expert Comment

ID: 8134700
Oh sorry!
try the following then:
<body onunload ="dosomething.jsp">

and in the dosomething.jsp write the code you want to run when exit.
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.


Author Comment

ID: 8135158
hello thanassis, this is not working. when i close the explorer window ,error message come up "undefined dosomething".
i think by using body unload my problem would not be solved.becoz if i click on a hyperlink or a submit button still the form gets unload and onunload event triggers. i want that this event trigger only when the form gets closed by clicking the close button of explorer window or by ending task by using (ctrl+alt+delete).
LVL 14

Accepted Solution

kennethxu earned 160 total points
ID: 8136692
Basically, there is no strait forward way to do this. The only event related to this is the body unload event. This event will be triggered when current page is out, the same event will triggered when you navigate to next page, back and forward and close windows.

To do this you’ll need a hidden frame structure. Make a frameset, 1st frame is 0% in size and have a page  contains <body onunload="location.replace('windowclose.jsp')">, the 2nd frame is 100% in size and contains your website pages.
LVL 35

Expert Comment

ID: 10041133
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

- Points to kennethxu

Please leave any comments here within the next seven days.


EE Cleanup Volunteer

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An introduction to the wonderful sport of Scam Baiting.  Learn how to help fight scammers by beating them at their own game. This great pass time helps the world, while providing an endless source of entertainment. Enjoy!
Microsoft has changed the look and feel of Azure AD and Microsoft account sign-in pages so that you will have a more unified look and feel when moving between the two interfaces.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question