PDA

View Full Version : appendChild failes in IE


jonaveen
10-20-2006, 09:28 AM
Offcourse this isn't a new one :) but...

... It works most of the time. I've written a script that uses a hidden IFrame to do a request to the server. The reponse is contained within a textarea, that I parse and then use to create elements in the top document (so not in the IFrame).

I do it like this: (sorry the code is in dutch, but have to stick to customer regulations :( )

function voegResultaatToe()
{
var regels = sResultaat.split("\n");

var oBereik = document.createDocumentFragment();
var oTabel = document.createElement("TABLE");

oTabel.id = oInvoegPunt.id.concat("_sub");
oBereik.appendChild(oTabel);
for (var i = 0; i < regels.length; i++)
{
var eigenschappen = regels[i].split(";");
var oRegel = oTabel.insertRow(oTabel.rows.length);
var oCel = oRegel.insertCell(0);
var oNieuweLink = document.createElement("A");

if (eigenschappen.length > 2)
{
var oSubLink = document.createAttribute("A");
//oSubLink.appendChild(document.createTextNode("+"));
oCel.appendChild(oSubLink); // <-- Results in "No such interface supported"
oSubLink.addEventListener("click", klapUit(oTabel.id, eigenschappen[2]), false);
}
oCel.appendChild(oNieuweLink);
oNieuweLink.href = eigenschappen[1];
oNieuweLink.appendChild(document.createTextNode(eigenschappen[0]));
}
oInvoegPunt.appendChild(oBereik);
}

All the appendChild calls work, except for the oCell.appendChild(oSubLink). That gives "No such interface supported" in IE 6. I'm stunned, because the cell is created in the document. It might be because i'm using a cell, and it doesn't support nodes by default, but then how can I get a node? Or should I simply use innerHTML and add code?

jonaveen
10-20-2006, 09:41 AM
Oops! Bad mistake on my part. Typed createAttribute instead of createElement and then tried to add it anyway. That won't work. I'm very very sorry if I wasted someones time. :o

There is another problem in this code, but I'll open a new thread for it.