yeah. before Dan introduced the "precreation"-system (to write all child-layers into the layer using a div-/layer-string) all layers were inserted using new Layer() in ns4, document.createElement() in DOM-browsers and the same as now in ie4. we changed to the precreation/div-string-methods since it improved speed a lot and i think i made ns4 more stable as well.
/martin -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of Josh Chu Sent: den 26 november 2001 17:42 To: Doug Melvin; [EMAIL PROTECTED] Subject: Re: [Dynapi-Help] How the Dynapi writes layers/divs to the browser Thank you! This has definitely shed some light on this for me. It turns out that the DynAPI does actually write the <DIV> tag contents to the browser, which is what I've seen done before. Just looking at specificCreate, this isn't entirely obvious...I had thought the DynAPI was using Javascript to manipulate/add to the DOM directly, and not through adding the <DIV> tags through some sort of document.write or innerHTML. Here's my trace through on how the DynAPI creates layers: 1) It calls the line parentElement.insertAdjacentHTML("beforeEnd",this.getOuterHTML()); or some other such variant for other browsers. 2) This will build a string which contains the <DIV> or <LAYER> (ns4) tags 3) This string is appended to the parent. This is the equivalent of doing a document.write("<DIV props>...</DIV>") in the parent element. This is great! Thanks! --JC ----- Original Message ----- From: Doug Melvin To: Josh Chu ; [EMAIL PROTECTED] Sent: Monday, November 26, 2001 9:50 AM Subject: Re: [Dynapi-Help] How the Dynapi writes layers/divs to the browser I didn't mean to indicate that your question was silly. Only that the answers are there to be found. If you didn't understand what you read, we probably can't help you.. I mean that you'd be better off reading an advanced Javascript totorial. Alright: ns6 file://note: I am not very strong on DOM, someone may want to correct me or fill in the blanks file://find the parent of the new layer var parentElement=(this.parent.isDynLayer)?this.parent.elm:this.parent.doc.b ody; //add a 'range' to the parent : same as adding an element? Maybe an empty HTML element var r = parentElement.ownerDocument.createRange(); //I assume this tells the 'range' where in the document it starts r.setStartBefore(parentElement); //create the HTML layer element (<div> or <layer>) var ptxt = r.createContextualFragment(this.getOuterHTML()); //probably add's it to the document parentElement.appendChild(ptxt); //DynAPI stuff.. //This allows DynAPI internal code to acces the object's JS Object //(the DynLayer is actualy an object that contains a Layer object) this.elm=parentElement.lastChild; //gives DynAPI direct access to the CSS properties of the layer object this.css=this.elm.style; //give a reference to the object's document this.doc=this.parent.doc; --- IE: //uses Microsft DOMish syntax to create the layer: //find a reference to the parent of the new layer var parentElement=(this.parent.isDynLayer)?this.parent.elm:this.parent.doc.b ody; //create the HTML layer element (<div> or <layer>) parentElement.insertAdjacentHTML("beforeEnd",this.getOuterHTML()); //obtain a reference to the actual layer object this.elm=parentElement.children[parentElement.children.length-1]; //obtain a reference to the new layer's CSS attributes this.css=this.elm.style; //Obtain a reference to the new Layer's document this.doc=this.parent.doc; And I think you said you understood the NS4 stuff.. I should add that to avoid memory leaks in NS4, any layers that area deleted are put into and array instead of being actually deleted so that they can be re-used the next time we need a layer. _______________________________________________ Dynapi-Help mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/dynapi-help