Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #21658
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!newsfeed.datemas.de!uucp.gnuu.de!newsfeed.arcor.de!newsspool2.arcor-online.net!news.arcor.de.POSTED!not-for-mail |
|---|---|
| Content-Type | text/plain; charset="UTF-8" |
| Message-ID | <4035931.IXUBZ7Uc5o@PointedEars.de> (permalink) |
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
| Reply-To | Thomas 'PointedEars' Lahn <cljs@PointedEars.de> |
| Organization | PointedEars Software (PES) |
| Date | Sat, 19 Oct 2013 23:45:41 +0200 |
| User-Agent | KNode/4.10.5 |
| Content-Transfer-Encoding | 8Bit |
| X-Face | %i>XG-yXR'\"2P/C_aO%~;2o~?g0pPKmbOw^=NT`tprDEf++D.m7"}HW6.#=U:?2GGctkL,f89@H46O$ASoW&?s}.k+&.<b';Md8`dH6iqhT)6C^.Px|[=M@7=Ik[_w<%n1Up"LPQNu2m8|L!/3iby{-]A+#YE}Kl{Cw$\U!kD%K}\2jz"QQP6Uqr],./"?;=4v |
| Face | iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEXTxa4RFk5dUWANED8PFEfy7+MGBiW+n3ZNF/QuAAACaElEQVQ4jVXUwVOcMBQG8Dc7Rc4PUntdWV2uxjDpGaGeozOp1woar4jd5t/v9wLstMwsA/ntlxdCAgUc1hjTc9/JCZfGoo3wG3HdmdAWrIJRHe7GM/TmpY5VFefuVcAkkPbLIaN8rmPmjloyZxgyR3GuJ4K0AGtJ2htz8o7yqikm759fldQXaMpbDzjKAG+8v+AugVTOPO5DOjLvGtUYQwh0CPjnVMyGd+8/GfUB5nLKJDD2aLDh5HYyMDJGDwQIo2ZmZcKbowNmAdB/AzyFhrmF2MHRb0QJJfaAnwGB6orZhoykLzJtGwF/xpYxI1dswomiUj3gTuAIqCn/4C7cULwGNBtwMTk3Y4LfKB5YUaOKBKYtpplm7u0vip8tU1NWWyI/7XdcSuIDoMt6rVHMWT0DbjHPGqDqZVSa6zleLcUTcIKLoMv3ueJluALtAo9B302zPPlrtiVScRdCjXvVh3e3JpYa/jjkuC9N+LrBMlz/eAN4eQijX2EdLo6c5tGGHwLyHFtXk89dDGHwCVhG9T0S/j55AhRZgkMCmUQXJ49TnS1wnQDvw0eAh9ICeMmEFbCnPMFzjAvsWoEWEFdYEx+S0MoUZ1gT1wId8+AF3Bl2OoEu906AUHx5VLw/gXYg/x84loOah/2UYNrgiwSwGO7RfUzVBbx/kgpckumGOi6QirtD6gkLTitbnxNol47S2jVc2vsN5kPqaAHT8uUdAJM4v/DanjYOwmUjWznGfwB7sGtAtor5BgofDuzaRj4kSQAqDakTsKORa3Q3xKi3gE1fhl71KRMqrdZ2AWNNg/YOhQyrVBnb+i+nEg4bsDA+egAAAABJRU5ErkJggg== |
| Subject | Re: prob with js... |
| Newsgroups | comp.lang.javascript |
| References | <l3u1fg$lr7$1@shakotay.alphanet.ch> <0cc5ab2c-9864-4ee8-8306-1d5eaf1e0849@googlegroups.com> |
| MIME-Version | 1.0 |
| Lines | 60 |
| NNTP-Posting-Date | 19 Oct 2013 23:45:57 CEST |
| NNTP-Posting-Host | 8de870a4.newsspool4.arcor-online.net |
| X-Trace | DXC=hWAb6TgmMlCgj[ZPFj7ehO4IUK<Cl32<A4Fo<]lROoRA8kF<OcfhCOK9aNUc68?K]HDZm8W4\YJNLYUVHKH;GI^GlT0o1c^2g0OWT042IRLhi@ |
| X-Complaints-To | usenet-abuse@arcor.de |
| Xref | csiph.com comp.lang.javascript:21658 |
Show key headers only | View raw
Danny wrote:
> To Une Bévue
Will you *please* learn to quote?
> this one is the case why using innerHTML property is not very reliable for
> READS, only for WRITES, that is, if you inject or ADD the elements to the
> document by using .innerHTML, the WRITE, that is, the ADDITION goes fine,
> but if you try to read any of the elements, like retriving by using the ID
> or even crawling the document tree to it, won't work very well.
Nonsense.
> for instances in which you need to READ elements or access elements added
> to the document, do not use the .innerHTML property, instead use the DOM
> methods like .createElement() and .appendChild() and .createTextNode().
Nonsense. The issue with the “innerHTML” is not unreliable read access; it
is mostly proprietary subtree serialization. But that has nothing to do
with the fact that you can add elements with “+=”; it is just inefficient
because previous siblings need to be serialized.
> Long as the DOM methods may be, and often maybe even redundantly worded,
> they're very reliable when accessing or adding elements to the document.
Very likely the issue here is the common one that the element with ID
“growlnotifications” has not been parsed yet when
this.growlnotifications = document.getElementById('growlnotifications');
is executed. As a result, this.growlnotifications is assigned “null”, and
the assignment in
this.setText = function (text) {
this.growlnotifications.innerHTML = text;
};
fails with something like
|> (null).answer = "42";
| TypeError: Cannot set property 'answer' of null
Therefore, your suggestion will not work.
this.setText = function (text) {
document.getElementById('growlnotifications').innerHTML=text;
};
works because the element object reference is not retrieved before the
setText() method is called, after the element has been parsed. The solution
is not to call the wrapper constructor before the element has been parsed;
it should be called in the “load” event listener for the “body” element
instead.
--
PointedEars
Twitter: @PointedEars2
Please do not Cc: me. / Bitte keine Kopien per E-Mail.
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
prob with js... Une Bévue <unbewusst.sein@fai.invalid> - 2013-10-19 15:29 +0200
Re: prob with js... Danny <dann90038@gmail.com> - 2013-10-19 13:02 -0700
Re: prob with js... Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-10-19 23:45 +0200
Re: prob with js... Une Bévue <unbewusst.sein@fai.invalid> - 2013-10-20 06:57 +0200
Re: prob with js... JJ <duh@nah.meh> - 2013-10-20 17:41 +0700
Re: prob with js... Une Bévue <unbewusst.sein@fai.invalid> - 2013-10-21 08:50 +0200
Re: prob with js... dhtml <dhtmlkitchen@gmail.com> - 2013-10-20 05:25 -0700
Re: prob with js... Une Bévue <unbewusst.sein@fai.invalid> - 2013-10-21 08:52 +0200
csiph-web