appendChild

ana
19 de Mayo del 2003
Hola:
Mi pregunta es la siguiente:
En javascript he hecho una tabla con sus correspondientes celdas y lo he creado de la siguiente manera:
row = document.createElement( "TR" );
tbody.appendChild( row ) ;
cell = document.createElement( "TD" );
row.appendChild( cell );
Me funciona, pero si inserto un <a href=""> no funciona, alguien sabe como hacerlo?

Gracias
Un saludo

Itan
19 de Mayo del 2003
¿Dónde quieres añadir el enlace? ¿dentro de la tabla?

Haber si esto te vale:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><title>Introducir enlace</title></head>
<body>
<table>
<tr>
<td>hola</td>
<td> como estas </td>
</tr>
<tr>
<td> espero que </td>
<td id="dondeva">aqui enlace: </td>
<td>bien</td>
<script type="text/javascript">
<!--
//document.getElementById("dondeva").removeChild(document.getElementById("dondeva").firstChild)
var contenidoenlace = document.createTextNode("Cuabipe de Itan");
var elementoenlace = document.createElement("a");
elementoenlace.setAttribute("id", "elenlace");
elementoenlace.setAttribute("href", "http://www.iespana.es/cuabipe/");
document.getElementById("dondeva").appendChild(elementoenlace);
document.getElementById("elenlace").appendChild(contenidoenlace);
//-->
</script>
</body></html>

Itan
19 de Mayo del 2003
quita el punto y coma que hay antes del cierre de parentesis de la línea elementoenlace.setAtrribute("href",...