How do I take a string and create an html fragment with it in IE. This works fine in non-ie browsers.
var str = "<div>Foo</div>";
var range = document.createRange();
var frag = range.createContextualFragment(str);
var e = document.getElementById("element");
e.appendChild(frag);
createContextualFragmentis not at all necessary considering the widespread adoption ofinnerHTML. Here are a couple answers that use document fragments to avoid the dangling extra div you'd get with a straightinnerHTMLapproach: stackoverflow.com/questions/814564/… and stackoverflow.com/questions/788614/…