Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!news.weisnix.org!newsfeed.ision.net!newsfeed2.easynews.net!ision!newsfeed.arcor.de!newsspool1.arcor-online.net!news.arcor.de.POSTED!not-for-mail Content-Type: text/plain; charset="ISO-8859-1" Message-ID: <4160767.OKRth7XBi8@PointedEars.de> From: Thomas 'PointedEars' Lahn Reply-To: Thomas 'PointedEars' Lahn Organization: PointedEars Software (PES) Date: Tue, 21 Feb 2012 13:54:33 +0100 User-Agent: KNode/4.4.11 Content-Transfer-Encoding: 7Bit Subject: Re: onclick=function(){obj.meth()} Newsgroups: comp.lang.javascript References: <1fb5k75j7mbjn04fm251o1omb0u1l1rbqv@4ax.com> <3b8b871f-22ad-4e04-b27e-c0342d295576@s9g2000yqj.googlegroups.com> Followup-To: comp.lang.javascript MIME-Version: 1.0 Lines: 54 NNTP-Posting-Date: 21 Feb 2012 13:54:37 CET NNTP-Posting-Host: 1bf9a886.newsspool3.arcor-online.net X-Trace: DXC==gf7P?Sd3]O02Sh8E_NfIAMcF=Q^Z^V3H4Fo<]lROoRA8kFJL X-Complaints-To: usenet-abuse@arcor.de Xref: x330-a1.tempe.blueboxinc.net comp.lang.javascript:11994 Richard Cornford wrote: > On Feb 21, 3:05 am, Gene Wirchenko wrote: >> On Tue, 21 Feb 2012 01:03:52 -0000, Richard Cornford wrote: >>> Puzzled wrote: >> [snip] >>>> This is what I'm trying to do: >>>> onclick = "this.some_method_identifier( arg, arg )" >>>That is meaningless in javascript terms precisely because the >>> value of the - this - keyword is not decided at this point. >> >> Huh? Is it not going to be the control that the onclick is for? It is. > Not necessarily, it depends on how the function is call. In response > to user interaction the browsers will reliably call the function as a > method of the DOM element with which it is associated (thus arranging > that the value of the - this - keyword is that DOM element), but it is > possible (indeed trivial) to call that function in a way that will > give the - this - keyword any value you choose. In Javascript the > value of the - this - keyword is decided (always and only) by how a > function is called. I do not see your point, and it appears you are preaching to the choir. If that is an event-handler attribute value, then the OP is correct. The way the function named `some_method_identifier' is called is *there*, in the attribute value. There is no ambiguity (host object issues aside) about the *initial* `this' value in the context of that method (if it is callable). >> [snip] >> >>> Computer programming is about understand enough to take control, which >>> is the antithesis of 'magic'. >> >> Plenty of magic deals with taking control. >> "One ring to rule them all..." > > Citing fiction in order to make a point about magic actually makes my > point. Fiction is as relevant to reality (which is where computer > programming goes on) as poetry or religion. That depends on whether that fiction is pure fantasy or based on scientific thought. Consider Star Trek (not the reboot), for example. (It is not by pure coincidence that I have a smartphone powered by an operating system named *Android*.) PointedEars -- Sometimes, what you learn is wrong. If those wrong ideas are close to the root of the knowledge tree you build on a particular subject, pruning the bad branches can sometimes cause the whole tree to collapse. -- Mike Duffy in cljs,