try:window.onload=function()
{var left=100;
var top=200;
for(var i=0;i<10;i++)
{temp = eval("layer"+i);
temp.style.left=parseInt(temp.style.left)+left;
temp.style.top=parseInt(temp.style.top)+top;
}
}注意看看layer大小写有没有错。
{var left=100;
var top=200;
for(var i=0;i<10;i++)
{temp = eval("layer"+i);
temp.style.left=parseInt(temp.style.left)+left;
temp.style.top=parseInt(temp.style.top)+top;
}
}注意看看layer大小写有没有错。
temp.style.left=parseInt(temp.style.left)+left;
temp.style.top=parseInt(temp.style.top)+top;
改成
alert(parseInt(temp.style.left)+left);
alert(parseInt(temp.style.top)+top;
就没问题
赋值就出错
我以前的一个客户也出现过这种错误,我让他重装系统,之后一切正常
temp = eval("document.all('layer" + i+"')"); temp.style.left=parseInt(temp.style.pixelLeft.substring(0,temp.style.pixelLeft.indexOf('px')))+left; temp.style.top=parseInt(temp.style.pixelTop.substring(0,temp.style.pixelTop.indexOf('px')))+top;
}