Connecting Tech Pros Worldwide Help | Site Map

onbeforeunload + server notification

  #1  
Old May 17th, 2007, 04:25 PM
Salvatore Sanfilippo
Guest
 
Posts: n/a
Hello,

I need to notify the server that the user closed a window.
In order to do so I tried to use the onbeforeunload event
to create an image object having as url the GET request
I need to perform to hint a PHP file server-side.

With firefox this is not working, I guess the page is flushed
away before the browser can load the image.

Is there some alternative solution not involving popups
or other nasty tricks?

Thanks in advance

Regards,
Salvatore

p.s. syncronous ajax is not an option since the server
is in a different domani.

  #2  
Old May 17th, 2007, 11:15 PM
scripts.contact
Guest
 
Posts: n/a

re: onbeforeunload + server notification


On May 17, 9:20 am, Salvatore Sanfilippo <anti...@gmail.comwrote:
Quote:
Hello,
>
I need to notify the server that the user closed a window.
In order to do so I tried to use the onbeforeunload event
to create an image object having as url the GET request
I need to perform to hint a PHP file server-side.
>
With firefox this is not working, I guess the page is flushed
away before the browser can load the image.
>
try onunload event -
note that opera fires the onunload only when you navigate away from
webpage or refresh the page but not when you close the tab/window.


  #3  
Old May 18th, 2007, 11:15 AM
Salvatore Sanfilippo
Guest
 
Posts: n/a

re: onbeforeunload + server notification


On May 18, 12:09 am, "scripts.contact" <scripts.cont...@gmail.com>
wrote:
Quote:
try onunload event -
note that opera fires the onunload only when you navigate away from
webpage or refresh the page but not when you close the tab/window.
This is working much better while not 100% reliable.
I also found that creating the image object in the body
via body.innerHTML += "< img src..." for some reason
improve the reliability.

Thank you for the help.

Regards,
Salvatore

Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
IE 7 showing User still Login when Close and Open again ? luqman answers 20 July 6th, 2007 04:05 PM
Remote Window Close Notification in Firefox and IE GEL answers 5 July 23rd, 2005 09:58 PM