How to track system generated dialog box/window?

V

Vasu

Hi

i have a web application that is developed suign struts. When the user
clicks the 'X' button in the window, i want to move to an action class
that performs a database update and then has to close the window.

Kindly help.

Let me know if theres any issue with teh code below:


JSP
-------


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<title>Untitled Document</title>
<script>
function doUnload(){
if (window.event.clientX < 0 && window.event.clientY < 0) {
alert("Window is closing...");
document.form.action="logout.do";
}
}
</script>
</head>
<body onunload="doUnload()">
<a href="http://www.yahoo.com">Yahoo</a>
</body>
</html>

Struts-config.xml
-----------------------------

<action path="/logout"
type="com.bt.osat.actions.ActionProductStatus"
scope="session"
<forward name="success" path="/jsp/logout.jsp"/>
<forward name="failure" path="/jsp/failure.jsp"/>
<forward name="Invalid"
path="/jsp/NoAuthentication.jsp"/>
<forward name="sessionexpired"
path="/jsp/sessionexpired.jsp"/>
</action>


Thanks in advance.

Regards,
Vasu
 
V

Vasu

I anyway found my mistake.

i had not submitted the form.

Heres the jsp code:

<SCRIPT language=javascript>



function doUnload()
{
window.document.forms[0].action="logout.do";
window.document.forms[0].method="post"
window.document.forms[0].submit();
}
</SCRIPT>
this works fine for alt+f4 and the 'X' button too.
 
A

Andrew Thompson

Vasu wrote:

Please refrain from top-posting.
I anyway found my mistake.

The real mistake is depending on 'onunload' to
be called at all.
....
this works fine for alt+f4 and the 'X' button too.

On your browser, on your OS? That is unfortunate for you..

I would expect clicking the close 'X' button to get rid of
the UA (browser), and any remaining stray windows.

Post your 'solution' to comp.lang.javascript, and watch
them ruin it on a dozen browsers, running on a variety
of OS's.. ( I dare you ;)

Andrew T.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top