Connecting Tech Pros Worldwide Help | Site Map

onbeforeunload + server notification

 
LinkBack Thread Tools Search this Thread
  #1  
Old May 17th, 2007, 03:25 PM
Salvatore Sanfilippo
Guest
 
Posts: n/a
Default onbeforeunload + server notification

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, 10:15 PM
scripts.contact
Guest
 
Posts: n/a
Default 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, 10:15 AM
Salvatore Sanfilippo
Guest
 
Posts: n/a
Default 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

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.