• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Help the body "onunload" attribute FAILS with AOL

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello I am using the following HTML/javascript to call a servlet on a window "onunload" event (see code below). apparently it works in most browsers except for AOL. Can any recommend a solution?
=============================================================
<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">

function deletehandle() {
yyy ='/compass/servlet/ChatDelete';
window.open(yyy, ' ' ,'height=1,width=1,scrollbars=no,titlebar=no,alwaysraised=no')
}
</script>
</HEAD>
<body onunLoad="deletehandle();" text="#fffff" bgColor="#003366" alink="#ffffff" link="#ffff66" vlink="#999900">
</body>
</html>
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Most likely it is a pop up blocker, If anyone has Service Pack 2 installed, uses Firefox, Mozilla, have a pop up blocker installed, then it WILL not work.

Looks like you need to find another way of ending your session.

Eric
 
Roland gray
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's not a popup blocker because the AOL user can view popups on the other pages of the site. If anyone else knows of other events I can trap to end a session please let me know.
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why use a popup window? How annoying.

If you just need to submit a servlet "behind the scenes" submit it to a hidden iframe.
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It most likely blocks onunload popups, try popping one onload.

Eric
 
Roland gray
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
[If you just need to submit a servlet "behind the scenes" submit it to a hidden iframe.]

A hidden iframe??? How does that help me to capture an exit event when a user closes a browser or leaves by entering another URL?


Besides I thought that Iframes were a microsoft based object. How about support for the other browsers?

AOL
Netscape
Mozila
opera
Firefox
etc..
 
Ranch Hand
Posts: 413
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First, iframe tag is supported by anything, except NS4 I would think.
What Bear Bibeault means is you need to call your url some other way, than opening a new window. It could be iframe, frame, image, etc.
Here is example:

 
Roland gray
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yuriy, you are right!

I forgot all about using an image source to call the servlet. Any ideas on other ways to handle a window exit without using the onunload event?
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is no way to detect when the browser window is closed...onunload is the closet you are going to get to it.

Just a few points to ponder as you develop this application:
You need to consider that the onunload gets call when the page is closed, user navigates away by link or typing in url, and refreshing the page. So if you need to distinguish between these, then you will have some difficulty.

The onunload event will not fire if user gets disconnected from internet, user's browser freezes, or my favorite reason "If JavaScript is disabled by the user"

That is why I really on my session timing out on the server to clean up the mess.

Regards,
Eric Pascarello
 
Roland gray
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yuriy, the script that you wrote and listed below works in Mozilla but not with Internet Exploer 5.5. There was no javascript error, the servlet was simply not called. Any ideas?

<script>
function doIt()
{
document.images["myImg"].src='/compass/servlet/ChatDelete';
}
</script>
<body onunload=doIt()>
<img name=myImg src="">
</script>

I addition I order to get it to work with Mozilla you don't even need to add
and image to the page. All you have to do is the following

<script>
var x= new Image();
x.src= "/compass/servlet/ChatDelete"
</script>

Unfortunately neither method seems to work for IE 5.5. Any Ideas??

Hey Eric thanks for the heads up..
[ December 06, 2004: Message edited by: Roland gray ]
 
Roland gray
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK Eric,

Since no one can resolve the question in my prior post. Can you describe how you use session IDs to clean up when someone leaves your site.
 
Roland gray
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey don't just answer the easy questions that we all know the answers to. Please help to resolve some real enterprise integration issues like this one. Please refer to the prior posts.
 
Yuriy Fuksenko
Ranch Hand
Posts: 413
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For this kind of "real enterprise integration issues" usually used combination is session timeout + session listener on a server side.

But if you just want that img method to be working in IE 5.5 and Mozilla, than you should use onbeforeunload event for IE type browser and onunload for Mozilla.
[ December 13, 2004: Message edited by: Yuriy Fuksenko ]
 
Roland gray
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Yuriy,

I will give that "onbeforeunload" a try. Can you please talk more about this
"session timeout + session listener on a server side". I am very familiar with a host of techniques for integrating applications but I believe that in this case I am not sure if we are on the same page. As a result can you please be so kind as to walk though an example of how a combination of the "session timeout + session listener" would work?

Are you simply referring to logging out a user after a certain amount of inactivity? If Yes, don't you think that most users would consider this a pain especially when considering the type of application (Chat Client)

Kind Regards
[ December 15, 2004: Message edited by: Roland gray ]
reply
    Bookmark Topic Watch Topic
  • New Topic