Hey guys.. Given <body id="body"> <a href="somewhereelse.html">Go Somewhere else</a> </body> Can I Event.observe($(''body''),''unload'',function(e) { alert(''on unload''); Event.stop(e); }); To trap the unload on the page? I''m specifically checking for the ''dirty status'' of a form.. and I confess I haven''t played around a lot with this but in my simple tests, the Unload wasn''t firing... Gareth --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Prototype used to use the following line: Event.observe(window, ''unload'', Event.unloadCache, false); Perhaps you need to have "window" be your observer, and not "body". TAG On Aug 29, 2007, at 8:51 PM, Gareth Evans wrote:> Hey guys.. > > Given > > <body id="body"> > <a href="somewhereelse.html">Go Somewhere else</a> > </body> > > Can I > > Event.observe($(''body''),''unload'',function(e) { alert(''on unload''); > Event.stop(e); }); > > To trap the unload on the page? > I''m specifically checking for the ''dirty status'' of a form.. and I > confess I haven''t played around a lot with this but in my simple > tests, the Unload wasn''t firing... > > Gareth > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
"body" doesn''t trigger unload. To invoke onunload Close the current browser window. Navigate to another location by entering a new address or selecting a Favorite. Click the Back, Forward, Refresh, or Home button. Click on an anchor that refers the browser to another Web page. Invoke the anchor click method. Invoke the document write method. Invoke the document open method. Invoke the document close method. Invoke the window close method. Invoke the window open method, providing the possible value _self for the window name. Invoke the window navigate or NavigateAndFind method. Invoke the location replace method. Invoke the location reload method. Specify a new value for the location href property. Submit a FORM to the address specified in the ACTION attribute via the INPUT_submit control, or invoke the form submit method. Default action Removes the object or document from the browser window. So, try ... Event.observe(window, ''unload'', function(e) { Event.stop(e); alert(''onunload''); }); But all that will do is alert you. You cannot stop the browser from closing. On 30/08/2007, Gareth Evans <agrath-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hey guys.. > > Given > > <body id="body"> > <a href="somewhereelse.html">Go Somewhere else</a> > </body> > > Can I > > Event.observe($(''body''),''unload'',function(e) { alert(''on unload''); > Event.stop(e); }); > > To trap the unload on the page? > I''m specifically checking for the ''dirty status'' of a form.. and I confess I > haven''t played around a lot with this but in my simple tests, the Unload > wasn''t firing... > > Gareth > > > > >-- ----- Richard Quadling Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 "Standing on the shoulders of some very clever giants!" --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thanks Richard I''ll bet thats what I was missing.. I figured since the ''onload'' event was on the body tag, that the ''unload'' event would also be there. Your post was very helpful, thanks again Gareth On 8/30/07, Richard Quadling <rquadling-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> > > "body" doesn''t trigger unload. > > To invoke onunload > Close the current browser window. > Navigate to another location by entering a new address or selecting a > Favorite. > Click the Back, Forward, Refresh, or Home button. > Click on an anchor that refers the browser to another Web page. > Invoke the anchor click method. > Invoke the document write method. > Invoke the document open method. > Invoke the document close method. > Invoke the window close method. > Invoke the window open method, providing the possible value _self for > the window name. > Invoke the window navigate or NavigateAndFind method. > Invoke the location replace method. > Invoke the location reload method. > Specify a new value for the location href property. > Submit a FORM to the address specified in the ACTION attribute via the > INPUT_submit control, or invoke the form submit method. > > Default action Removes the object or document from the browser window. > > So, try ... > > Event.observe(window, ''unload'', function(e) { Event.stop(e); > alert(''onunload''); }); > > But all that will do is alert you. You cannot stop the browser from > closing. > > On 30/08/2007, Gareth Evans <agrath-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Hey guys.. > > > > Given > > > > <body id="body"> > > <a href="somewhereelse.html">Go Somewhere else</a> > > </body> > > > > Can I > > > > Event.observe($(''body''),''unload'',function(e) { alert(''on unload''); > > Event.stop(e); }); > > > > To trap the unload on the page? > > I''m specifically checking for the ''dirty status'' of a form.. and I > confess I > > haven''t played around a lot with this but in my simple tests, the Unload > > wasn''t firing... > > > > Gareth > > > > > > > > > > > > -- > ----- > Richard Quadling > Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 > "Standing on the shoulders of some very clever giants!" > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---