Visit Mozilla.org

DOM:range.createContextualFragment

From MDC

« Gecko DOM Reference

Contents

[edit] Summary

Returns a document fragment.

[edit] Syntax

documentFragment = range.createContextualFragment( tagString )

[edit] Parameters

tagString 
Text that contains text and tags to be converted to a document fragment.

[edit] Example

var tagString = "<div>I am a div node</div>";
var range = document.createRange();
range.selectNode(document.getElementsByTagName("div").item(0));
var documentFragment = range.createContextualFragment(tagString);
document.body.appendChild(documentFragment);

[edit] Notes

This method takes a string and uses Mozilla's parser to convert it to a DOM tree.

[edit] Specification

This method is not part of a specification.