Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #16406
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeder2.ecngs.de!ecngs!feeder.ecngs.de!xlned.com!feeder1.xlned.com!npeer.de.kpn-eurorings.net!npeer-ng0.de.kpn-eurorings.net!newsfeed.arcor.de!newsspool2.arcor-online.net!news.arcor.de.POSTED!not-for-mail |
|---|---|
| Content-Type | text/plain; charset="ISO-8859-1" |
| Message-ID | <2931754.sreIk3pbUD@PointedEars.de> (permalink) |
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
| Reply-To | Thomas 'PointedEars' Lahn <cljs@PointedEars.de> |
| Organization | PointedEars Software (PES) |
| Date | Fri, 05 Oct 2012 01:02:01 +0200 |
| User-Agent | KNode/4.4.11 |
| Content-Transfer-Encoding | 7Bit |
| 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: appendChildren versus innerhtml |
| Newsgroups | comp.lang.javascript |
| References | <DfmdneLFAvpwlfPNnZ2dnUVZ_uWdnZ2d@westnet.com.au> |
| Followup-To | comp.lang.javascript |
| MIME-Version | 1.0 |
| Lines | 58 |
| NNTP-Posting-Date | 05 Oct 2012 01:02:01 CEST |
| NNTP-Posting-Host | 398c025b.newsspool1.arcor-online.net |
| X-Trace | DXC=OjMeB<Oh96J^B]`=U:WelBic==]BZ:afN4Fo<]lROoRAnkgeX?EC@@@>32E0LlHXPKDZm8W4\YJNLR=i2=[N6Y6JI8d2_XC2HW@k0D5aVUC[YM |
| X-Complaints-To | usenet-abuse@arcor.de |
| Xref | csiph.com comp.lang.javascript:16406 |
Followups directed to: comp.lang.javascript
Show key headers only | View raw
Andrew Poulos wrote: > If the server can return "arbitrary" but valid HTML such as > > "<div id='textbox01' style='position:absolute; left:36px; top:92px; > overflow: visible;'>" + > "<div style='position:absolute; left:0px; top:0px; width:496px; > height:488px; overflow:auto ; border-radius: 0px 0px 0px 0px'></div>" + > "<div style='position:absolute; left:0px; top:0px; width:496px; > height:488px; overflow:auto ; border-radius: 0px 0px 0px 0px'>" + > "<div style='; padding-left:0px; padding-right:0px; padding-top:0px; > padding-bottom:0px'>" + > "<p style='margin-top:0pt;margin-bottom:0pt;'><span > style='font-size:14pt;color:#000000;font-weight:bold;'><sup>The > Emergence</sup></span></p>" + > "<p style='margin-top:0pt;margin-bottom:0pt;'><span > style='color:#000000;'>The effect of globalisation and, more. > </span></p>" + > "<p style='margin-top:0pt;margin-bottom:0pt;'><span > style='color:#000000;'> </span></p>" + > "<p style='margin-top:0pt;margin-bottom:0pt;'><span > style='color:#000000;'>I propose to consider </span></p>" + > "<p style='margin-top:0pt;margin-bottom:0pt;'><span > style='color:#000000;'></span></p>" + > "</div></div></div>" + > "<div id='kb1' style='position:absolute; left:572px; top:208px; > width:400px; height:264px;'><img id='kb1img' > src='images/020808_1633_0030_lsls.jpg' alt='extreme' title='' > style='position:absolute; left:0px; top:0px; width:100%; height:100%; > margin:0;'></div>" > > how can you possibly parse it and use createElement/appendChild to > recreate the HTML. Currently I'm using innerHTML. You can parse this efficiently using a regular expression containing token patterns matching grammar atoms in alternation and RegExp.prototype.exec(), then apply createElement/appendChild on the result. Unless you use setAttribute(), certain attributes must be handled specially because of their non-identifier name. The `style' attribute must be handled as a special case, i.e. you need to parse the attribute value to set style properties; either with the bracket property accessor syntax and a mapper for non-identifier style property names, or with CSSStyleDeclaration::setProperty(). ISTM you should prefer the `innerHTML' branch if that property is available and applicable to your use-case; it may be still proprietary but it merely encapsulates what browsers do best (within their limits): parse HTML so that the result can be rendered. But why does the server return HTML in the first place? 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, <news:Xns9FB6521286DB8invalidcom@94.75.214.39>
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
appendChildren versus innerhtml Andrew Poulos <ap_prog@hotmail.com> - 2012-10-05 08:08 +1000
Re: appendChildren versus innerhtml Danny <dann90038@gmail.com> - 2012-10-04 15:41 -0700
Re: appendChildren versus innerhtml Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-10-05 01:02 +0200
Re: appendChildren versus innerhtml Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-10-05 01:25 +0200
Re: appendChildren versus innerhtml Andrew Poulos <ap_prog@hotmail.com> - 2012-10-05 09:58 +1000
Re: appendChildren versus innerhtml Martin Honnen <mahotrash@yahoo.de> - 2012-10-05 11:36 +0200
Re: appendChildren versus innerhtml Andrew Poulos <ap_prog@hotmail.com> - 2012-10-06 18:31 +1000
Re: appendChildren versus innerhtml Matt McDonald <matt@fortybelow.ca> - 2012-10-05 15:46 -0400
csiph-web