Hi, On Oct 22, 7:47 pm, JoJo <tokyot...@gmail.com> wrote: > Thanks T.J. > > The solution is: > ...
FWIW, it's a bit off-topic, but regarding your code where you're defining and then calling a function: function(parameter) { // ... }(localVariable) To ensure that that works reliably across implementations, you'll want to wrap the function expression in parentheses: (function(parameter) { // ... })(localVariable) I don't remember my source for the information, but I remember that I trusted the source. It seems to me your version _should_ work according to the spec, and I know it does for other things, but I think some significant implementation has an issue with generating the call without clarifying it as with the parens above. Happy coding, -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com On Oct 22, 7:47 pm, JoJo <tokyot...@gmail.com> wrote: > Thanks T.J. > > The solution is: > > dynamicAnchor = new Element( > 'a', { > href: 'javascript:void(0)' > } > ).observe( > 'click', > function(parameter) { > return function(event) { > window.status = parameter; > Event.stop(event); > } > }(localVariable) > ); > > On Oct 22, 4:39 am, "T.J. Crowder" <t...@crowdersoftware.com> wrote: > > > > > > > > > Hi, > > > See the documentation for `Event.observe`[1] (which is what you're > > calling indirectly from the `Element#observe` function), specifically > > the "Preventing the Default Event Action and Bubbling" part, and the > > `Event` object[2]: You don't return false to cancel the `click` event, > > you use the `Event#preventDefault` function (which is a standard DOM > > function[3] that Prototype ensures is present even on implementations > > that lack it) or, more likely, `Event#stop`[4] which both prevents the > > default action and stops the event bubbling. > > > [1]http://api.prototypejs.org/dom/event/observe/ > > [2]http://api.prototypejs.org/dom/event/ > > [3]http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-Event-prev... > > [4]http://api.prototypejs.org/dom/event/stop/ > > > HTH, > > -- > > T.J. Crowder > > Independent Software Engineer > > tj / crowder software / com > > www / crowder software / com > > > On Oct 22, 2:41 am, JoJo <tokyot...@gmail.com> wrote: > > > > I use anchors to call javascript functions. Usually, I do this: > > > > <a href="javascript:void(0)" onclick="someFunc(); return false;"> > > > call the function > > > </a> > > > > This works fine in all browsers. Window.onbeforeunload is never > > > triggered because the ONCLICK returns false, and thus the HREF if not > > > executed. When HREF is not executed, the browser does not believe that > > > the window in unloading. Now, I'm trying to create a dynamic anchor to > > > accomplish the same thing. It looks nearly identical to the HTML > > > anchor, but now it's triggering window.onbeforeunload in IE8. How do I > > > not trigger it? > > > > dynamicAnchor = new Element( > > > 'a', { > > > href: 'javascript:void(0)', > > > } > > > ).observe( > > > 'click', > > > function(parameter) { > > > return function() { > > > window.status = parameter; > > > return false; > > > } > > > }(localVariable) > > > ); -- 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-scriptacul...@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.