Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #14105
| From | Matt McDonald <matt@fortybelow.ca> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: FAQ Topic - How do I modify the content of the current page? (2012-05-23) |
| Date | 2012-05-22 18:07 -0600 |
| Organization | A noiseless patient Spider |
| Message-ID | <jph9nt$8vb$1@dont-email.me> (permalink) |
| References | <4fbc1a7a$0$294$14726298@news.sunsite.dk> |
On 12-05-22 05:00 PM, FAQ server wrote: > If the new content is only text and does not need to replace existing HTML, > it is more efficient to modify the `data` property of a text node. A more general approach is simply to use the `nodeValue` property, though both are acceptable. > Compatibility Note: Implementations have been known to split long text > content among several adjacent text nodes, so replacing the data of the > first text node may not replace all the element's text. The `normalize` > method, where supported, will combine adjacent text nodes. The DOM 4 specification states[0] that textual content replacement (`Node::textContent`, setting) is to be done by clearing the `childNodes` of a node and appending a text node containing the new text for Element and DocumentFragment nodes, while simply replacing the `data` (and by proxy the `nodeValue`) for Text, ProcessingInstruction and Comment nodes. I've written a fork of `textContent` (to be released soon) that does precisely this. Since Element nodes are the most desired context, the former behavior is advised. [0]: http://dvcs.w3.org/hg/domcore/raw-file/tip /Overview.html#dom-node-textcontent -- Matt McDonald: Web/Flash Developer; Edmonton, Alberta, Canada
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
FAQ Topic - How do I modify the content of the current page? (2012-05-23) "FAQ server" <javascript@dotinternet.be> - 2012-05-22 23:00 +0000
Re: FAQ Topic - How do I modify the content of the current page? (2012-05-23) Matt McDonald <matt@fortybelow.ca> - 2012-05-22 18:07 -0600
Re: FAQ Topic - How do I modify the content of the current page? (2012-05-23) Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-05-23 19:57 +0200
csiph-web