Prev: validating a form, one required field 2
Next: FAQ Topic - How do I POST a form to a new window? (2010-06-29)
From: Thomas 'PointedEars' Lahn on 29 Jun 2010 04:24 Garrett Smith wrote: > On 2010-06-28 06:26 PM, Garrett Smith wrote: >> I recommended *agaist* using that approach whenever I see it because it >> doesn't work in IE. > > Correction: Because it doesn't work cross-browser. ACK, my bad. I do not agree with some of your conclusions, though. More later. PointedEars -- Anyone who slaps a 'this page is best viewed with Browser X' label on a Web page appears to be yearning for the bad old days, before the Web, when you had very little chance of reading a document written on another computer, another word processor, or another network. -- Tim Berners-Lee
From: Thomas 'PointedEars' Lahn on 29 Jun 2010 05:13 Garrett Smith wrote: > On 2010-06-28 05:07 PM, Thomas 'PointedEars' Lahn wrote: >> Garrett Smith wrote: >>> Thomas 'PointedEars' Lahn wrote: >>>> RobG wrote: >>>>> The code in the article has a $() function that simply calls >>>>> document.getElementById() and is used precisely once. So to save >>>>> typing 22 characters, the author wrote a function of 53 characters >>>>> and spaces (plus a bunch more for the comment). Consider using >>>>> instead: >>>>> >>>>> var $ = document.getElementById; >>>>> >>>>> within the scope it is required. No global "$", no extra function >>>>> call, far fewer characters to transmit and exactly (more or less) the >>>>> same functionality. >>>> >>>> It does not work as you suggest because the calling object would not be >>>> that referred to by `document' anymore, but the Global Object. As a >>>> result, at least MSHTML would throw an exception. I had to observe >>>> that when writing JSX:dhtml.js years ago and I presume it still holds >>>> true. So a wrapper is required if you want an alias for this, but it >>>> should have a better, self-descriptive identifier (like `dom.getEBI' >>>> etc. in >>>> JSX:dhtml.js). Since then this method included also feature testing >>>> for the MSHTML 4 and NS 4 DOMs, but it would appear that these can >>>> either be safely discarded in the near future or moved to compatibility >>>> libraries. >>> I see your case, but I have a few disagreements. >> >> Well, you are rather prone to misconceptions. > > Aside from the typo that Stephen Weiss caught (thanks), did I post > something wrong? Seems not. > > You referred to "base object" as "calling object" and called that global > object. That's wrong terminology. "base object" is wrong terminology, too. "`this' value" would be correct. > If the aforementioned code been defined in global context, then yes, the > base object would be the global object, Questionable. > but I disagree with calling that a "calling object" because it is not the > correct terminology. The concept was clear, though. >>> Calling a host method with a different base object won't work in most >>> browsers. >> >> I believe I have said that. >> >>> [preaching to the choir] > > I did not write that. That's called a summary, stupid. >>> This is old news, appearing in an old post of erik's weblog: >>> "appendChild is not a function" and > > http://erik.eae.net/archives/2006/04/27/17.50.15/ > > Whether or not Erik was wrong about other points doesn't really matter. > That entry is the one that counts here. > >> You don't mean the guy that completely botched JScript/MSHTML, do you? > > Dunno about that, Apparently you didn't mean him. Which keeps your argument fallacious, though. > but the entry itself points out the fact I stated. > it's quoted so search google for that string and you'll see. > > Here... Let's eat sh*t -- a million flies can't be wrong. PointedEars -- Prototype.js was written by people who don't know javascript for people who don't know javascript. People who don't know javascript are not the best source of advice on designing systems that use javascript. -- Richard Cornford, cljs, <f806at$ail$1$8300dec7(a)news.demon.co.uk>
From: Stefan Weiss on 29 Jun 2010 05:57 On 29/06/10 10:23, Thomas 'PointedEars' Lahn wrote: > Garrett Smith wrote: >> On 2010-06-28 05:30 PM, Thomas 'PointedEars' Lahn wrote: >>> There, I knew it (I cannot remember ever having written code without good >>> reason): >> >> Knew what? That the base object matters in most browsers? > > No, that I had a reason for not using a simple alias as suggested by > _Stefan_. JFTR, I didn't suggest this. I did admit (in a different thread, a about two months ago) that I sometimes use $ as a shortcut for document.getElementById, but not in the form of a direct reference. I use something like |var $ = someObj.gEBI|, which doesn't have the problem discussed in this thread, as long as gEBI doesn't make use of its |this| value. -- stefan
From: Thomas 'PointedEars' Lahn on 29 Jun 2010 06:46 Stefan Weiss wrote: > Thomas 'PointedEars' Lahn wrote: >> Garrett Smith wrote: >>> On 2010-06-28 05:30 PM, Thomas 'PointedEars' Lahn wrote: >>>> There, I knew it (I cannot remember ever having written code without >>>> good reason): >>> Knew what? That the base object matters in most browsers? >> No, that I had a reason for not using a simple alias as suggested by >> _Stefan_. > > JFTR, I didn't suggest this. [...] You're absolutely right. Sorry, Garrett got me confused with his "Stephen Weiss" in <news:i0bh3v$426$1(a)news.eternal-september.org>. RobG suggested it, of course, in <news:e4b6f243-8fe3-4d0a-8999-6c18027a3c7a(a)x24g2000pro.googlegroups.com> earlier in this thread, and it was (t)his posting that my correction was directed at (albeit the correction itself was evidently flawed). PointedEars -- Anyone who slaps a 'this page is best viewed with Browser X' label on a Web page appears to be yearning for the bad old days, before the Web, when you had very little chance of reading a document written on another computer, another word processor, or another network. -- Tim Berners-Lee
From: Garrett Smith on 29 Jun 2010 14:26 On 2010-06-29 02:57 AM, Stefan Weiss wrote: > On 29/06/10 10:23, Thomas 'PointedEars' Lahn wrote: >> Garrett Smith wrote: >>> On 2010-06-28 05:30 PM, Thomas 'PointedEars' Lahn wrote: >>>> There, I knew it (I cannot remember ever having written code without good >>>> reason): >>> >>> Knew what? That the base object matters in most browsers? >> >> No, that I had a reason for not using a simple alias as suggested by >> _Stefan_. > > JFTR, I didn't suggest this. Right, well Thomas' last few posts have seemed not very rational and contained a number of mistakes. RobG made that suggestion and right after advising to use document.getElementById. He mentioned th drawbacks to creating a wrapper, as I did and pointed out that it's unnecessary, as I did. ISTM the subject of how to use getElementById been done to death. But maybe not. > I did admit (in a different thread, a about two months ago) that I > sometimes use $ as a shortcut for document.getElementById, but not in > the form of a direct reference. I use something like |var $ = > someObj.gEBI|, which doesn't have the problem discussed in this thread, > as long as gEBI doesn't make use of its |this| value. > That works so long as `someObj.gEBI` does not make references to `this`, expecting it to be `someObj`. But, what also works: document.getElementById Just remember not to give any element's NAME a value that equals another element's ID, and vice-versa. Garrett
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 4 Prev: validating a form, one required field 2 Next: FAQ Topic - How do I POST a form to a new window? (2010-06-29) |