Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Session destroy on window close

 
Rizwan Qadri
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I want to destroy the session by closing window. and I dont want refresh to work also . For that i have written code . But Its running on IE 6 but not on IE 7.
Please help.


<html>
<script>
function doUnload()
{
alert("doUnload");
if (window.event.clientX < 0 && window.event.clientY < 0)
{
alert("Window is closing...");
}
}
</script>
<body onunload="doUnload()">

</body>
</html>


Thanks,

Rizwan
 
Lorand Komaromi
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rizwan Qadri wrote:Hi,
But Its running on IE 6 but not on IE 7.


Did you allow IE to run scripts? (you know, that annoying yellow bar..?)

As a sidenote, you shouldn't rely on onunload, the user might have disabled JS or he could kill IE's process using the task manager, in neither case would your handler be called!
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65115
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The only deterministic way to do this is to rely upon the session time-out.
 
Rizwan Qadri
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But the question remains that why it is running in IE 6 but not in IE 7?
 
Lorand Komaromi
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rizwan, the question remains: is JS enabled in IE7..?
 
Rizwan Qadri
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ya, JS is enabled in IE7
 
Lorand Komaromi
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try with || instead of &&! And good luck with making it work in other browsers!

(Btw, how is your problem related to JSP..?)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic