Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!news1.tnib.de!feed.news.tnib.de!news.tnib.de!news.belwue.de!newsfeed.arcor.de!newsspool2.arcor-online.net!news.arcor.de.POSTED!not-for-mail Content-Type: text/plain; charset="ISO-8859-1" Message-ID: <1963616.aqSPkdTlGX@PointedEars.de> From: Thomas 'PointedEars' Lahn Reply-To: Thomas 'PointedEars' Lahn Organization: PointedEars Software (PES) Date: Mon, 27 Feb 2012 17:40:40 +0100 User-Agent: KNode/4.4.11 Content-Transfer-Encoding: 7Bit Subject: Re: How to programmatically display a value Newsgroups: comp.lang.javascript References: <1403837.V9SEqChMir@PointedEars.de> <4f4b98cd$0$6909$e4fe514c@news2.news.xs4all.nl> Followup-To: comp.lang.javascript MIME-Version: 1.0 Lines: 45 NNTP-Posting-Date: 27 Feb 2012 17:40:40 CET NNTP-Posting-Host: 89f9032f.newsspool1.arcor-online.net X-Trace: DXC=31B9l75G2Q1D]ncZ]`hZ;1ic==]BZ:af>4Fo<]lROoR1<`=YMgDjhg2kCF7l1W35V5DZm8W4\YJN81SB1JXVAXd9 X-Complaints-To: usenet-abuse@arcor.de Xref: x330-a1.tempe.blueboxinc.net comp.lang.javascript:12202 Erwin Moller wrote: > On 2/25/2012 1:19 PM, Thomas 'PointedEars' Lahn wrote: >> Cal Who wrote: >>> I don't know if this is the "best" way to display a numeral but I found >>> the innerHTML property on the span element and that appears to work OK. >> >> You are displaying a numeral, not parsing HTML markup; using innerHTML is >> overkill, not standardized, and therefore error-prone. Use the >> `nodeValue' property of the `firstChild' of the span element object (you >> should provide it with a child node, say ). > > Why did you say using innerHTML is error-prone? > > Are you saying it is error-prone *because* it is not standardized? > Or it it error-prone for a different reason? Both. > I ask because I never encountered any problems using innerHTML for > simple tasks like displaying a number. Because it is a simple task and it is only a number string, not markup, `innerHTML' is overkill. It is also proprietary and error-prone. Therefore, it is best avoided here. > What is it are you warning for here? We really have discussed this ad nauseam here. To reiterate: The `innerHTML' property facilitates only a proprietary de-/serialization of the document tree, entirely at the discretion of the implementor. Among other things, this means that you can write to the `innerHTML' property but you cannot know if this worked. There is no exception thrown and reading back the property value very likely yields a different string value than the one you previously wrote to it. `innerHTML' breaks with tables, except when you generate the whole table with `innerHTML'. `innerHTML' also (very obviously) is not supposed to work in XHTML. All this is very different with the standardized DOM manipulation methods. PointedEars -- Danny Goodman's books are out of date and teach practices that are positively harmful for cross-browser scripting. -- Richard Cornford, cljs, (2004)