Links

Lists

Latest Updates

Ruby On Rails List
Python list
Advanced Java
The JavaScript List
Apache Users
Full Disclosure
Linux Security

Search the archives!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Javascript] Problem w/Javascript, interpolation, functions, onclick


  • From: mwarden at gmail.com (Matt Warden)
  • Subject: [Javascript] Problem w/Javascript, interpolation, functions, onclick
  • Date: Wed Oct 25 12:45:03 2006

On 10/25/06, Paul Novitski <paul@xxxxxxxxxxxxxxxxxxx> wrote:
>                  // now act on the object whose behavior triggered
> this function
>                  var sClass = this.tagName;       // etc.

This is incorrect. In IE, events are executed in the window scope, so
when you do this.tagName, it is equivalent to doing window.tagName.
You must get the target element from the event itself, as I suggest
here:

http://mwarden.f2o.org/sandbox/getidfromeventhandler.js

You can alternatively specify the scope in which the handler should
run. YUI does this. You can see how they are doing it in their source:

doc:
http://developer.yahoo.com/yui/docs/event/YAHOO.util.Event.html#addListener

source:
http://developer.yahoo.com/yui/docs/event/overview-summary-Event.js.html

-- 
Matt Warden
Cleveland, OH, USA
http://mattwarden.com


This email proudly and graciously contributes to entropy.