dizzle
10-26-2004, 09:36 AM
Wondering if someone could check this code, trying to find out why it doesn't work in IE... The function takes a table object as an argument, and creates a similarly shaped table and offsets it behind the original for a shadow effect. Works good in Mozilla.
function makeShadow(strTableName) {
var tblOriginal = getElementByBrowser(strTableName);
var tblShadow = document.createElement("TABLE");
tblShadow.id = strTableName + ".shadow";
tblShadow.border = tblOriginal.border;
tblShadow.setAttribute("border","0");
tblShadow.setAttribute("cellPadding",tblOriginal.getAttribute("cellPadding"));
tblShadow.setAttribute("cellSpacing",tblOriginal.getAttribute("cellSpacing"));
tblShadow.setAttribute("height",tblOriginal.clientHeight);
tblShadow.setAttribute("width",tblOriginal.clientWidth);
tblShadow.setAttribute("class","shadow");
for (i=0;i<tblOriginal.rows.length;i++) {
tblShadow.insertRow(i);
tblShadow.rows[i].setAttribute("class",tblOriginal.rows[i].getAttribute("class"));
tblShadow.rows[i].setAttribute("style",tblOriginal.rows[i].getAttribute("style"));
for (j=0;j<tblOriginal.rows[i].cells.length;j++) {
tblShadow.rows[i].insertCell(j);
tblShadow.rows[i].cells[j].setAttribute("class",tblOriginal.rows[i].cells[j].getAttribute("class"));
tblShadow.rows[i].cells[j].setAttribute("style",tblOriginal.rows[i].cells[j].getAttribute("style"));
tblShadow.rows[i].cells[j].bgColor = "#888888";
tblShadow.rows[i].cells[j].bordercolor = "#888888";
tblShadow.rows[i].cells[j].style.background = "#888888";
strBackground = tblOriginal.rows[i].cells[j].style.background;
if (strBackground.indexOf("transparent") > -1) {
tblShadow.rows[i].cells[j].style.background = "transparent";
}
tblShadow.rows[i].cells[j].colSpan = tblOriginal.rows[i].cells[j].colSpan;
tblShadow.rows[i].cells[j].rowSpan = tblOriginal.rows[i].cells[j].rowSpan;
tblShadow.rows[i].cells[j].setAttribute("width",tblOriginal.rows[i].cells[j].clientWidth);
tblShadow.rows[i].cells[j].setAttribute("height",tblOriginal.rows[i].cells[j].clientHeight);
}
}
tblShadow.style.left = DL_GetElementLeft(tblOriginal) + 4;
tblShadow.style.top = DL_GetElementTop(tblOriginal) + 4;
docBody = document.getElementsByTagName("body").item(0);
docBody.appendChild(tblShadow);
}
getElementByBrowser() works, I know this. The problem with IE is that it writes the shadow table, but will not move it behind the original. It ends up being appended to the page. Any suggestions?
function makeShadow(strTableName) {
var tblOriginal = getElementByBrowser(strTableName);
var tblShadow = document.createElement("TABLE");
tblShadow.id = strTableName + ".shadow";
tblShadow.border = tblOriginal.border;
tblShadow.setAttribute("border","0");
tblShadow.setAttribute("cellPadding",tblOriginal.getAttribute("cellPadding"));
tblShadow.setAttribute("cellSpacing",tblOriginal.getAttribute("cellSpacing"));
tblShadow.setAttribute("height",tblOriginal.clientHeight);
tblShadow.setAttribute("width",tblOriginal.clientWidth);
tblShadow.setAttribute("class","shadow");
for (i=0;i<tblOriginal.rows.length;i++) {
tblShadow.insertRow(i);
tblShadow.rows[i].setAttribute("class",tblOriginal.rows[i].getAttribute("class"));
tblShadow.rows[i].setAttribute("style",tblOriginal.rows[i].getAttribute("style"));
for (j=0;j<tblOriginal.rows[i].cells.length;j++) {
tblShadow.rows[i].insertCell(j);
tblShadow.rows[i].cells[j].setAttribute("class",tblOriginal.rows[i].cells[j].getAttribute("class"));
tblShadow.rows[i].cells[j].setAttribute("style",tblOriginal.rows[i].cells[j].getAttribute("style"));
tblShadow.rows[i].cells[j].bgColor = "#888888";
tblShadow.rows[i].cells[j].bordercolor = "#888888";
tblShadow.rows[i].cells[j].style.background = "#888888";
strBackground = tblOriginal.rows[i].cells[j].style.background;
if (strBackground.indexOf("transparent") > -1) {
tblShadow.rows[i].cells[j].style.background = "transparent";
}
tblShadow.rows[i].cells[j].colSpan = tblOriginal.rows[i].cells[j].colSpan;
tblShadow.rows[i].cells[j].rowSpan = tblOriginal.rows[i].cells[j].rowSpan;
tblShadow.rows[i].cells[j].setAttribute("width",tblOriginal.rows[i].cells[j].clientWidth);
tblShadow.rows[i].cells[j].setAttribute("height",tblOriginal.rows[i].cells[j].clientHeight);
}
}
tblShadow.style.left = DL_GetElementLeft(tblOriginal) + 4;
tblShadow.style.top = DL_GetElementTop(tblOriginal) + 4;
docBody = document.getElementsByTagName("body").item(0);
docBody.appendChild(tblShadow);
}
getElementByBrowser() works, I know this. The problem with IE is that it writes the shadow table, but will not move it behind the original. It ends up being appended to the page. Any suggestions?