Hi, If you assign a string to event.returnValue, that will work on Firefox and IE:
Event.observe(window, 'beforeunload', function(event) { event.returnValue = "Really leave?"; }); But it doesn't work on Chrome, Safari, or Opera, so it's of fairly limited use. :-) I'm not aware of a cross-platform way of doing this except with a DOM0 handler (assigning directly to the property, happily bludgeoning anyone else's handler there), which seems...wrong. -- T.J. Crowder tj / crowder software / com www.crowdersoftware.com On Sep 15, 10:16 am, JoJo <tokyot...@gmail.com> wrote: > I have this code and it works very well: > > ++++++++++++++++++++++++++++ > > window.onbeforeunload = function() { > if (this.hasUnsavedChanges) { > return 'you have unsaved changes'; > } > > }.bind(this); > > +++++++++++++++++++++++++++++ > > But when I try to convert it to Prototype style, it doesn't work. I > get no confirmation box asking me if I want to stay on the page. I > want to be as cross-browser compatible as possible, so could someone > help me do it the Prototype way? > > ++++++++++++++++++++++++++++ > > Event.observe( > window, > 'beforeunload', > function() { > if (this.hasUnsavedChanges) { > return 'you have unsaved changes.'; > } > }.bind(this) > ); --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~----------~----~----~----~------~----~------~--~---