supponi di ricevere i dati via xml e che il tuo contenitore sia un div con id=id_nodo
con un po' di css abbellisci il tuttocodice:// crea il nuovo nodo var new_node = document.createElement('div'); new_node.setAttribute('id', 'id_nodo'); // questo nodo avrà una intestazione // il nodo header var header = document.createElement('div'); header.setAttribute('id', 'header'); // un corpo var body = document.createElement('div'); body.setAttribute('id', 'body'); // e un piedipagina var footer = document.createElement('div'); footer.setAttribute('id', footer'); // inseriamo nel footer il pulsante per chiudere var chiudi_btn = document.createElement('input'); chiudi_btn.setAttribute('type', 'button'); chiudi_btn.setAttribute('value', 'Chiudi'); chiudi_btn.setAttribute('id', 'btn_close'); chiudi_btn.setAttribute('onclick', "document.getElementById('" + "id_nodo" + "').style.display='none';"); chiudi_btn.style.cssText = "float:right";// lo mettiamo a destra, dove sono soliti essere // per msie, chiudi_btn.onclick = function () { document.getElementById(id_nodo).style.display="none"; }; footer.appendChild(chiudi_btn); // inserisci i tuoi dati nel header, footer e body ........ // ok leghiamo il tutto new_node.appendChild(header); new_node.appendChild(body); new_node.appendChild(footer); // ed invine inseriamolo nel flusso del documento (dove credi tu), per esempio in coda a body document.getElementsByTagName("body")[0].appendChild(new_node);
ciao
sergio

Rispondi quotando