Salut,
bon je suis pas sur de ce que je vais dire mais allons-y gaiement ^^
Si j'ai bien compris, ici
document.getElementById(idTableau).insertAdjacentHTML('beforeEnd',chaine);
tu essaies d'ajouter un <tr> entre </tbody> et </table>.
Donc déjà c'est pas au bon endroit, en plus :
note de la MSDN :
Note When using Dynamic HTML (DHTML) to create a document, you can create objects and set the innerText or innerHTML property of the object. However, because of the specific structure required by tables, the innerText and innerHTML properties of the table and tr objects are read-only.
Donc à vérifier mais insertAdjacentHTML ne doit à priori pas fonctionner sur un table. Tu peux tenter sur le tbody directement ca marchera peut-être.
Pour info y a plus simple (IE6/FF2) :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| <script>
function addRowToTable(tbodyId, cellContent) {
var tbody = document.getElementById(tbodyId);
// Création d'un élément ligne
row = document.createElement("tr");
// Création d'un élément colonne
col = document.createElement("td");
// Définition d'un attribut
col.setAttribute("height", "35");
// Ajout du texte dans la cellule
col.innerHTML = cellContent;
// Ajout de la colonne dans la ligne
row.appendChild(col);
// Ajout de la ligne au table
tbody.appendChild(row);
}
</script>
<p onClick="addRowToTable('tab', '<p>tret ert <em>er</em> ter ert er</p>');">Add</p>
<table border="1">
<tbody id="tab">
</tbody>
</table> |
Bye
Partager