[whatwg] Partial HTML5 documents

Garrett Smith dhtmlkitchen at gmail.com
Tue Dec 7 23:45:35 PST 2010


On 9/9/10, Rostislav Hristov <rostislav.hristov at gmail.com> wrote:
> Hello,
>
> I'm looking for a way to define valid partial HTML fragments that can
> be included into other documents using a server-side language or
> injected using AJAX. The current specification doesn't have any major
> restrictions in this area but it always require the presence of a
> TITLE tag which in this specific case is not needed. Does anybody have
> an idea if the TITLE can be skipped somehow or how this whole thing
> can be implemented properly? Do you think it should be specified?
>

I may have misunderstood, but it sounds like you might be able to use
createContextualFragment:
<http://html5.org/specs/dom-parsing.html#extensions-to-the-range-interface>

Example copy'n'pasted from c.l.js:

var s = "<script>alert(1)</script>";
var range = document.createRange();
range.selectNode(document.body);
var documentFragment = range.createContextualFragment(s);
document.body.appendChild(documentFragment);
-- 
Garrett



More information about the whatwg mailing list