我在下载文件时使用 JavaScript 制作进度条。我已经将它作为图片从服务器移动到客户端,但我不知道如何让它重复,所以进度会继续。我用过这个脚本。我需要做什么?
<style type="text/css">
#apDiv1 {
position:absolute;
width:142px;
height:140px;
z-index:1;
background-color: #FFFFFF;
background-image: url(server.png);
}
#apDiv2 {
position:absolute;
width:142px;
height:140px;
z-index:2;
left: 500px;
top: 15px;
background-color: #FFFFFF;
background-image: url(laptop.png);
}
#apDiv3 {
position:absolute;
width:346px;
height:140px;
z-index:3;
left: 153px;
top: 15px;
}
body {
}
</style>
<div id="apDiv1"></div>
<div id="apDiv2"></div>
<div id="apDiv3"><br />
<script type="text/javascript">
<!--
var imgObj = null;
var animate ;
function init(){
imgObj = document.getElementById('myImage');
imgObj.style.position= 'relative';
imgObj.style.left = '0px';
}
function moveRight(){
imgObj.style.left = 200 + 200 + 'px';
if (10 <= left) {
imgObj.style.left = (left + 300) + 'px';
imgObj.style.visibility='visible';
} else
if (left>=500) {
imgObj.style.left = '0px';
}
}
function animate(){
animate = setTimeout(moveRight,200);
}
window.onload =init;
//-->
</script>
</head>
<body>
<form>
<img src="file:///C|/Documents and Settings/Administrator/Desktop/New Folder (2)/folder.png" width="65" height="67" id="myImage" />
<p>Click the buttons below to handle animation</p>
<input type="button" value="Shkarko" onclick="moveRight();" />
</form>
</div>