Once I create a range how do I display the HTML content of it in Firefox?
range.toString()
only gives me the text content. In essence, like innerHTML returns the markup in IE.
Thanks
function innerHTML(oTarget, sContent, bAppend){
if (document.getElementById && !document.all) {//is this a non ie browser
var range = document.createRange();
range.setStart(oTarget, 0);
range.setEnd(oTarget, oTarget.childNodes.length);
if (sContent) {//if there is content, save it if not return the content
var htmlFrag = range.createContextualFragment(sContent);
if (bAppend != true) {//append or replace
range.deleteContents();
}
oTarget.appendChild(htmlFrag); //add the new html
} else {
sContent = range.toString();
}
} else {
if (sContent) {
if (bAppend == true) {
oTarget.innerHTML += sContent;
} else {
oTarget.innerHTML = sContent;
}
}
sContent = oTarget.innerHTML;
}
return sContent;
}