PDA

Просмотр полной версии : progressbar


undeddy
08.02.2006, 18:54
Вот код:
<html>
<head>
<script>
function progress(){
var onePercent = 20;
var width = 20;
line.style.width = width;
width += 10;
setTimeout('progress()', 100);

}
</script>
</head>
<body onLoad = "setTimeout('progress()', 100);">

<DIV ID = "back" STYLE = "position: absolute; top: 150px; left: 200px; height: 20px; width: 300px; background-color: LightGrey"></DIV>
<DIV ID = "line" STYLE = "position: absolute; top: 150px; left: 200px; height: 20px; background-color: DimGray"</DIV>

</body>
</html>

Не пойму, почему не работает этот код? Ширина "line" не меняется.

Skubent
08.02.2006, 19:16
Потому что width определяется каждый раз при вызове функции.
И эта, line.style смени на document.getElementById('line').style