djstaz0ne
02-11-2010, 03:24 AM
replacechild is not working properly in ie7. I have looked around and have found no workaround. :confused: the following script works in ff, but not in ie:
Note: this code is stripped down to the bare minimum
This function is applied to all elements with a specific name using a for loop
function encloseElement(e){
cDiv = document.createElement('div');
cDiv.innerHTML = '<div style="width:50px; height:50px; background-color:#000000;"> </div>';
e.parentNode.replaceChild(cDiv, e);
}
Here is the loop used to cycle thru the elements
function drawPage(){
ctDivs = document.getElementsByName("content");
ctTopDivs = document.getElementsByName("ctTop");
rs = "";
for(i=0; i<ctDivs.length; i++){
encloseElement(ctDivs.item(i));
}
for(j=0; j<ctTopDivs.length; j++){
encloseElement(ctTopDivs.item(j));
}
}
Any help is appreciated.
Note: this code is stripped down to the bare minimum
This function is applied to all elements with a specific name using a for loop
function encloseElement(e){
cDiv = document.createElement('div');
cDiv.innerHTML = '<div style="width:50px; height:50px; background-color:#000000;"> </div>';
e.parentNode.replaceChild(cDiv, e);
}
Here is the loop used to cycle thru the elements
function drawPage(){
ctDivs = document.getElementsByName("content");
ctTopDivs = document.getElementsByName("ctTop");
rs = "";
for(i=0; i<ctDivs.length; i++){
encloseElement(ctDivs.item(i));
}
for(j=0; j<ctTopDivs.length; j++){
encloseElement(ctTopDivs.item(j));
}
}
Any help is appreciated.