On Apr 16, 12:35 am, Walter Lee Davis <[EMAIL PROTECTED]> wrote:
> In Prototype, you can get the target element itself this way:
>
> function doThis(evt){
>         var targetElement = Event.element(evt);
>         alert(targetElement.target);
>         alert(targetElement.up('div').id);
>         //or something like that
>
> }
>
> (I have a sneaking suspicion that using event as the variable name
> might cause some pain in IE. I usually stick to evt, but that's
> probably cargo cult on my part...)

Identifiers included in the parameter list of a function declaration
create local variables of the same name as if declared within the
function.  A function declaration like:

  function foo(event) {...}

may cause a problem is where it is expected that within the function
the unqualified use of the identifier event will resolve to the global
window.event property and not the local event variable.

Since window.event is a maifestation of the IE event model and there
are many browsers that implement a different event model (typically
Mozilla's), this issue is normally resolved as a consequence of
resolving the differences in event models, e.g.

  function foo(event) {
    event = event || window.event;
    ...
  }

Although I typically use 'e' rather than event anyway.  :-)


--
Rob
--~--~---------~--~----~------------~-------~--~----~
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@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to