views:

41

answers:

2

Hi,

If I load a page in an iframe, run doc.querySelect to retrieve a node N, append N to doc.body by doc.body.appendChild(N), and then remove all children from doc.body until it reaches N, would N be guaranteed to be rendered the same way as pristine in Firefox or IE? So far in the example that I have tried, it's alright, but I was wondering if it'd fail in other settings.

Thanks

A: 

I may be missing something, but why not copy the node, delete the children of doc.body, then append the node to the now empty doc.body? Use the cloneNode() method for copying the node.

Robusto
also a nice idea. don't forget to ignore the iframe while deleting :-)
henchman
Sure. But would the browser draw the node the same way as before the manipulation? Would deleting neighbour nodes affect the result of the drawing?
s.wong
Yes, of course it would. If you are not deleting any parentNodes, from which it might inherit CSS rules, everything should be fine.
Robusto
A: 

If you have valid markup and a corresponding doctype that should be fine :-)

henchman