Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!newsfeed.arcor.de!newsspool2.arcor-online.net!news.arcor.de.POSTED!not-for-mail Content-Type: text/plain; charset="UTF-8" Message-ID: <2394720.ArG6xLiZAS@PointedEars.de> From: Thomas 'PointedEars' Lahn Reply-To: Thomas 'PointedEars' Lahn Organization: PointedEars Software (PES) Date: Sun, 13 Nov 2011 20:26:47 +0100 User-Agent: KNode/4.4.11 Content-Transfer-Encoding: 8Bit Subject: Re: Difference between findPos("divThis") and findPos(divThis) Newsgroups: comp.lang.javascript References: <4775241.ypaU67uLZW@PointedEars.de> Followup-To: comp.lang.javascript MIME-Version: 1.0 Lines: 68 NNTP-Posting-Date: 13 Nov 2011 20:26:48 CET NNTP-Posting-Host: 32879286.newsspool4.arcor-online.net X-Trace: DXC=3G1hTJhK<;3NTD55K=4IUKMIK`IcM37_9 X-Complaints-To: usenet-abuse@arcor.de Xref: x330-a1.tempe.blueboxinc.net comp.lang.javascript:8289 Cal Who wrote: > "Thomas 'PointedEars' Lahn" wrote […]: >> Your OP was hard to read and not even syntactically valid; I have >> reformatted it and completed it. > > Also, I should have included the "..." that (I just added) to make cleared > that there was more code. ACK. >> Both approaches work in Internet Explorer and perhaps elsewhere in >> *Quirks Mode*. That is so because MSHTML, probably to make DOM scripting >> easier, elements with IDs are explicitly represented in the DOM by >> properties of the same name of the object referred to by `window'. >> >> That object (`window' object for short) is in the scope chain. So if you >> use the `divThis' identifier and no other object in the scope chain has a >> property of that name, it will be resolved to the property of the >> `window' object. The result is a reference to the DOM element object >> which represents the element. > > I don't have the backgroung to understand the above paragraph. I will answer specific, *smart* questions you may have. (So do not ask, for example, "What is a scope chain?", unless you want a "STFW" answer.) But I will still ignore you if you (continue to) post with an invalid From/Reply-To header field value. Usenet can only work if communication works both ways. > Is the first approch (var w = document.getElementById(obj).offsetWidth) > the better one? Yes and no. It is the better one if you pass the element's ID string for `obj'. It is not better if you call document.getElementById(obj) twice in the process. There are also cases where you do not need to call document.getElementById(); in that case it would be better not to call it. > If you are refering to: "How to Determine Positions of Elements" I was referring to the thread started with , Subject "David Mark's Javascript Tip Du Jour - Volume #1 - Tip #1234 - How to Measure Element Dimensions", which is what your posted code does. > I had read it and in fact have copied it and pasted into my file for later > testing, but he did not, I don't believe, mentioned this method which is > simpler and since I don't know why I should not rely on it I thought I'd > try it. Your posted code has nothing to do with the posting you are referring to. Please trim your quotes to the relevant minimum next time. HTH 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,