Greetings:
I wish to invoke a logout javascript function when the user exits the
browser.
What is the best practice for observing the beforeunload event using
prototype?
[RC2] Here''s an idea, but it doesn''t work for me.
document.observe(''contentloaded'', function(e){
Event.observe(window, ''beforeunload'', function(e) {
logout();
});
});
Thanks
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
I use this:
window.onbeforeunload = confirmExit;
function confirmExit() {
url = ''http://www.??.com/includes/logMe.php''
new Ajax.Request(url, { method: ''get''});
}
On Sep 6, 12:21 pm, JGHSBC
<jgr...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Greetings:
>
> I wish to invoke a logout javascript function when the user exits the
> browser.
>
> What is the best practice for observing the beforeunload event using
> prototype?
>
> [RC2] Here''s an idea, but it doesn''t work for me.
>
> document.observe(''contentloaded'', function(e){
> Event.observe(window, ''beforeunload'', function(e) {
> logout();
> });
>
> });
>
> Thanks
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
I''m looking for a prototype (i.e. Event.observe) solution. On Sep 6, 1:45 pm, Diodeus <diod...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I use this: > > window.onbeforeunload = confirmExit; > function confirmExit() { > url = ''http://www.??.com/includes/logMe.php'' > new Ajax.Request(url, { method: ''get''}); > > } > > On Sep 6, 12:21 pm, JGHSBC <jgr...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Greetings: > > > I wish to invoke a logout javascript function when the user exits the > > browser. > > > What is the best practice for observing the beforeunload event using > > prototype? > > > [RC2] Here''s an idea, but it doesn''t work for me. > > > document.observe(''contentloaded'', function(e){ > > Event.observe(window, ''beforeunload'', function(e) { > > logout(); > > }); > > > }); > > > Thanks- Hide quoted text - > > - Show quoted text ---~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Are you using prototype 1.6?? If so the reason your code isnt working
is because ''beforeunload'' isnt fully cross browser supported
and
therefore is not one of the events listed in Event.DOMEvents . This
causes it to be interepreted as a custom event in the Event.observe
code and is therefore mapped onto a ''dataavailable'' event. A
simple
fix for this is to add
if (!Event.DOMEvents.include(''beforeunload''))
Event.DOMEvents.push(''beforeunload'');
to your code somewhere before your observe. There may be a better
solution by the time 1.6 is released.
Tom
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---