Hello all:
We have a table with about 2400 cells. Our requirement is to highlight
the cells in the table whose data has changed, every 5 seconds. Our
script behaves relatively ok in Firefox, but the performance in IE
really bad. Have attached a simple html which simulates the prob. Any
inputs on how to improve the perf in IE are greatly appreciated.
Thanks,
Raj
---
<HTML>
<HEAD>
<style>
.normal_td { background-color: #DDDDDD }
.red_td { background-color: #FF0000 }
.blue_td { background-color: #0000FF }
</style>
<script language="JavaS cript1.2">
var kk=100;
function updateTableCell s()
{
var tbl = document.getEle mentById("tbl") ;
var tds = tbl.getElements ByTagName("td") ;
for(var k=0; k<tds.length;k+ +)
{
tds[k].firstChild.nod eValue = kk;
var rem = kk-(parseInt(kk/7)*7);
if(rem == 0)
setClassName(td s[k], "red_td");
else if(rem==5)
setClassName(td s[k], "normal_td" );
else if(rem==2)
setClassName(td s[k], "blue_td");
else
setClassName(td s[k], null);
kk++;
if(kk>10000)kk= 5000;
}
}
function setClassName(n, name){
if(n.className! =name)
n.className=nam e;
}
function init(){
var str="<table id='tbl'>";
for (var i=0;i<150;i++)
{
str+="<tr>\n";
for (var j=0;j<16;j++)
{
str+="<td id='ele"+i+"_"+ j+"'>"+j+"</td>\n";
}
str+="</tr>\n";
}
str +="</table>";
var bod = document.getEle mentById("bod") ;
bod.innerHTML=s tr;
setInterval('up dateTableCells( )','5000');
}
window.onload = init;
</script>
</HEAD>
<BODY id="bod"/>
</HTML>
We have a table with about 2400 cells. Our requirement is to highlight
the cells in the table whose data has changed, every 5 seconds. Our
script behaves relatively ok in Firefox, but the performance in IE
really bad. Have attached a simple html which simulates the prob. Any
inputs on how to improve the perf in IE are greatly appreciated.
Thanks,
Raj
---
<HTML>
<HEAD>
<style>
.normal_td { background-color: #DDDDDD }
.red_td { background-color: #FF0000 }
.blue_td { background-color: #0000FF }
</style>
<script language="JavaS cript1.2">
var kk=100;
function updateTableCell s()
{
var tbl = document.getEle mentById("tbl") ;
var tds = tbl.getElements ByTagName("td") ;
for(var k=0; k<tds.length;k+ +)
{
tds[k].firstChild.nod eValue = kk;
var rem = kk-(parseInt(kk/7)*7);
if(rem == 0)
setClassName(td s[k], "red_td");
else if(rem==5)
setClassName(td s[k], "normal_td" );
else if(rem==2)
setClassName(td s[k], "blue_td");
else
setClassName(td s[k], null);
kk++;
if(kk>10000)kk= 5000;
}
}
function setClassName(n, name){
if(n.className! =name)
n.className=nam e;
}
function init(){
var str="<table id='tbl'>";
for (var i=0;i<150;i++)
{
str+="<tr>\n";
for (var j=0;j<16;j++)
{
str+="<td id='ele"+i+"_"+ j+"'>"+j+"</td>\n";
}
str+="</tr>\n";
}
str +="</table>";
var bod = document.getEle mentById("bod") ;
bod.innerHTML=s tr;
setInterval('up dateTableCells( )','5000');
}
window.onload = init;
</script>
</HEAD>
<BODY id="bod"/>
</HTML>
Comment