Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 396
  • Last Modified:

Closing the explorer window.

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.
                                                   munish
0
manu2020
Asked:
manu2020
1 Solution
 
thanassisCommented:
You can use javaScript for that:

<a href="javascript: self.close()">Close window</a>
0
 
manu2020Author Commented:
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.
0
 
thanassisCommented:
Oh sorry!
try the following then:
<html>
<body onunload ="dosomething.jsp">
....

and in the dosomething.jsp write the code you want to run when exit.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
manu2020Author Commented:
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).
0
 
kennethxuCommented:
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.
0
 
girionisCommented:
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.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

girionis
EE Cleanup Volunteer
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now