*
The moose likes HTML, CSS and JavaScript and the fly likes logOut script not working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "logOut script not working" Watch "logOut script not working" New topic
Author

logOut script not working

Stephen Wei
Ranch Hand

Joined: Oct 09, 2001
Posts: 73
Hi, I am assuming user use IE browser which supports Javascript. I want my LogoutServlet to run when the user pushes the logout button or close the browser. Here is my code, but my servlet will not get executed, my browser closes ok(I want the browser to close when the user logout), why is this? When I remove the "window.close();" line, my servlet will execute, is it because my window closes too quickly before it submits the form?
< script language = "javascript">
function logOut()
{
window.event.returnValue = false;
if(confirm("logout´┐ŻH")){
window.event.returnValue = true;
window.close();
}
}
/script
< p
align="center"> < input type="submit" value="logout" action="http/myhost/Servlet/LogoutServlet"
"onclick"="logOut()"> //I put an extra quotation here because otherwise I could not submit this message to Javaranch, strange.
< /p>

Also, can someone explain the "onclose()" function to me? How do I submit a request to the servlet using only Javascript? something like:
Window.onclose(){
Document.myform.submit();
} /
???
Thanks!


Sun Certified Programmer for Java Platform
Vijay S. Rathore
Ranch Hand

Joined: Oct 29, 2001
Posts: 449
Hi,
In your logout servlet set some flag come back to the page read the flag and invoke window.close() after reading the flag in body onload instead of calling window.close() in logout function.


SCJP, SCJD, SCWCD1.4, IBM486, IBM484, IBM 483, IBM 287, IBM141, IBM Certified Enterprise Developer - WebSphere Studio, V5.0
Author of IBM 287 Simulator Exam
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: logOut script not working