Under what circumstances would there be an advantage to using this object in an html document?
Announcement
Collapse
No announcement yet.
createDocumentFragment:
Collapse
X
-
There is one large benefit to it - when you assign a DocumentFragment to another Node, the children of the DocumentFragment are assigned to the Node instead of the actual DocumentFragement. That means that you can assign multiple children at the same time instead of assigning them one at a time.liorean <[[email protected]]>
Articles: RegEx evolt wsabstract , Named Arguments
Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards
-
IIRC only Mozilla supports DocumentFragment for the moment, so it's kinda limited for the moment.liorean <[[email protected]]>
Articles: RegEx evolt wsabstract , Named Arguments
Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards
Comment
-
Yeah but check this: if you use cloneNode(true) to copy a node from an <object>-embedded HTML document, what you get back is not a node at all - it's a document fragment with your node as its first child. Since it's in a document fragment you can't append it using appendNode, or move it with insertAdjacentElement or insertBefore - you have to copy it with outerHTML.
Stupid browser..Last edited by brothercake; Feb 18, 2004, 02:52 AM."Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark
Comment
-
James - is that really the problem? How about trying to use Document.importNode first, and then trying to append it?liorean <[[email protected]]>
Articles: RegEx evolt wsabstract , Named Arguments
Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards
Comment
-
importNode doesn't work in IE - cloneNode is the only way to copy a node afaik.
It might be related the strangeness of accessing the document in the first place - IE has contentWindow.document when it's an iframe, but an <object> has no contentWindow, and IE doesn't support contentDocument, so the only way I could find to get the document is with a reference to the <object> itself. Like this example, trying to copy individual <ul> nodes out of another element in the embedded document:
Code:var obj = document.getElementById("someObject"); var doc = obj; var docElement = doc.getElementById("whatever"); var docTree = docElement.getElementsByTagName('ul')[0]; var docUL = docTree.cloneNode(true)
"Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark
Comment
-
Oh, ie quirkyness again. I was thinking that this was rather another problem: Nodes belong to a document. You can't use a node from one document in another without importing it.
But then I never counted on iew being standards compliant...
How about using Element.ownerDocument on an element in the object document?liorean <[[email protected]]>
Articles: RegEx evolt wsabstract , Named Arguments
Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards
Comment
-
With liorean's help, we debugged this particular issue - instead of using the reference to the object, using the object property of the object returns a #document node:
Code:var doc = obj.object;
Sorry this is all a bit OT though ...Last edited by brothercake; Feb 18, 2004, 09:14 PM."Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark
Comment
-
James: About importNode, have you seen this? <http://neo.dzygn.com/archives/individual/56>liorean <[[email protected]]>
Articles: RegEx evolt wsabstract , Named Arguments
Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards
Comment
Comment