Ciao a tutti!
Vorrei creare un div con un determinato testo quando viene inviato un form.
Ho trovato questa funzione
che richiamo nelle mia pagina conCodice:unction creatediv(id, html, width, height, left, top) { var newdiv = document.createElement('div'); newdiv.setAttribute('id', id); if (width) { newdiv.style.width = 300; } if (height) { newdiv.style.height = 300; } if ((left || top) || (left && top)) { newdiv.style.position = "absolute"; if (left) { newdiv.style.left = left; } if (top) { newdiv.style.top = top; } } newdiv.style.background = "#00C"; newdiv.style.border = "4px solid #000"; if (html) { newdiv.innerHTML = html; } else { newdiv.innerHTML = "nothing"; } document.body.container.appendChild(newdiv); }
Il div viene creato benissimo, il problema è che non è nella posizione 0;0, ma alla fine della pagina, sapete dirmi per quale motivo?Codice HTML:<form onSubmit="creatediv('div_id','testotesto',200,300,0,0);">
Come risolvo questo problema?
Grazie in anticipo!

LinkBack URL
About LinkBacks


