Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > createDocumentFragment

Reply
Thread Tools

createDocumentFragment

 
 
niels.bosma@gmail.com
Guest
Posts: n/a
 
      03-22-2006
(Working in FireFox)

I trying to build a minimal optimized HTML template engine in
JavaScript and I have some problems with what I trying to do.

I want in the most efficient way load a html file (valid XHTML) file
with XmlHttpRequest, parse it and insert into my html document.

var frag = document.createDocumentFragment();
frag.innerHTML = loadedSrc;

....fails.

Any suggestions?

 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      03-22-2006

wrote:

> I want in the most efficient way load a html file (valid XHTML) file
> with XmlHttpRequest, parse it and insert into my html document.


You say you want to load a valid XHTML document and then you want to
insert the complete XHTML into another HTML document? I don't understand
that, how does one complete document fit into another document?

As for loading XHTML with XMLHttpRequest in Firefox, either make sure
you serve the XHTML with an XML MIME type or use overrideMimeType to get
Firefox to parse the response as XML. Then you can use DOM Level 2
importNode to import nodes from one document (responseXML) into the
other (document) and afterwards DOM Level 2 Core methods like
appendChild or insertBefore or replaceChild work to have nodes inserted.


--

Martin Honnen
http://JavaScript.FAQTs.com/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments