On 8/19/07 4:59 AM, "David Burrowes" wrote:
> I pull a valid xhtml document back through an XMLHttpRequest (via
> responseXML), use getElementById() to extract a subtree, and try to
> insert it into the current (in the browser window) xhtml document.
>
> This works fine in firefox on the mac. Doesn't in Safari 2 or 3.
>
> Should this work? If so, is this a problem with Safari? If so, where do I
> report this? on the web kit web site or on the apple one?
Safari's behavior is correct according to the W3C DOM specification. The
correct way to insert parts of one document into another involves using
importNode (DOM L2 or L3) or adoptNode (L3) functions. (Most browsers
support L2 - I've used importNode in Opera/Firefox/Safari/IE).
So, if you have document A with a child node id=A1, and document B with a
child node id=B1, and you want to add A1 as a child of B1, this is what
you would do:
var a1 = a.getElementById( "A1" );
var b1 = b.getElementById( "B1" );
b1.appendChild( b1.ownerDocument.importNode( a1, true ) );
For more info on importNode, see the DOM spec at
http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#Core-Document-importNode
Hope that helps,
kats
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Web-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden