Why does browser experiences problem of unresponsive javascripts?.Can the problem be resolved by making the code into server-side?
here my code which becomes unresponsive on multiple clicks.
[CODE]
var x=document.getElementsByTagName('td');
var i,random;
var colors=["red","blue","green"];
function randomise()
{
random=colors[Math.floor(Math.random()*colors.length)];
}
function generate()
{
i=0;
while(i<54)
{
randomise();
if(random=="red")
{
x[i].bgColor=random;
i=i+1;
}
else if(random=="blue")
{
x[i].bgColor=random;
i=i+1;
}
else if(random=="green")
{
x[i].bgColor=random;
i=i+1;
}
}
}
[ICODE]
On a button click the function generate is being called,the script runs fine for the first click but after that it becomes unresponsive,whats the best solution Can writing the same code in php or any server-side language help me ?