PDA

View Full Version : Need help with JS and browser closing


JS Newbie
09-13-2000, 03:20 PM
I need to send a request to the CGI program (to log the user off the host system) whenever the user closes the browser (upper-right corner X). I have tried a number of things to achieve this. The lastest code is as follows:

In the main JS file, I have:

function x() {
logfWindow = window.open("exiting.htm","logfWindow");
// alert ("Logging of HOST....");
}

</Script>
</HEAD>
<BODY BGCOLOR="#000000" onLoad="parent.initHelp('general');init()" onUnload="x()">


The "exiting.htm" contains:
<HTML>
<BODY onLoad="document.lofform.submit()" onUnload="document.lofform.submit()">
<FORM NAME="lofform" action="../tstcgi1.cgi" method="post">
<INPUT TYPE="HIDDEN" NAME="debug" VALUE="no">
<INPUT TYPE="HIDDEN" NAME="service" VALUE="xxxx">
<INPUT TYPE="HIDDEN" NAME="2" VALUE="logf">
<INPUT TYPE="HIDDEN" NAME="svc-subsvc" VALUE="yyyy">
<INPUT TYPE="HIDDEN" NAME="cookie" VALUE="id">
</FORM>
Please wait while I am logging you OFF..........
</BODY>
</HTML>

This works ok ONCE, e.g. a new window opens, which says "Please wait.....blah-blah", the logoff command
"tstcgi1.cgi?debug=no&service=xxxx&2=logf&svc-subsvc=yyyy&cookie=id"
is sent, and the user is logged off. (I can see it in the CGI trace file). But, the next time, there is no new window, and therefore no command is sent to CGI.

Any ideas?