<SCRIPT LANGUAGE="JavaScript1.5">
HTMLElement.prototype.innerHTML setter =
function (html) {
while (this.hasChildNodes())
this.removeChild(this.lastChild);
this.innerHTMLInput = html;
var range = document.createRange();
range.setStartAfter(this);
var docFrag = range.createContextualFragment(html);
this.appendChild(docFrag);
};
HTMLElement.prototype.outerHTML setter =
function (html) {
this.outerHTMLInput = html;
var range = document.createRange();
range.setStartBefore(this);
var docFrag = range.createContextualFragment(html);
this.parentNode.replaceChild(docFrag, this);
}
</SCRIPT>
Does someone know whether mozilla exposes some api to construct a html
source string of a document fragment?? Then the getter functions would
be easy otherwise someone would need to write some dom traversal stuff.
--
Martin Honnen
http://home.t-online.de/home/martin.honnen/jsgoddies.html
NS6/Mozilla has the range.createContextualFragment() function, which can be
used to create a set of DOM elements from an HTML string.
Using this, I have duplicated insertAdjacentHTML(), insertAdjacentText() and
insertAdjacentElement() to NS6/Mozilla, and added the same insertion
behaviour as IE4/5 exposes.
http://chat.betachat.dk/dom/interactive.html
--
Thor Larholm
Does aybody know the equivalent of insertAdjacentHTML that workt in netscape
6?
I would like to let users of my site to dynamically insert combinations of
text en html into a document, so that it will work in netscape 6.
Is there an existing script for that?
Danny Goodman wrote this about is:
“When the dynamic content involves combinations of HTML elements and text
nodes, the DOM methodology gets more complex, since you have to create the
elements or text nodes and assemble the objects in the desired sequence”.
Unfortunatly he did not tell how or where to find a script like that.
Thanks.
charles.