<style type="text/css">
*{ margin:0px auto; padding:0px}
#kuang{ width:200px; height:10px; border:1px solid #60F;}
#jindu{ height:10px; background-color:#F03; float:left}
</style>
</head>
<body>
<br />
<div id="kuang">
	<div id="jindu" style="width:0px"></div>
</div>
<script type="text/javascript">
window.setTimeout("jindu()",30);
//调一下进度前进1%
function jindu()
{
	//获取进度div的宽度
	var div = document.getElementById("jindu");
	
	//获取到的是字符串"0px"
	var str = div.style.width;
	
	//处理字符串获取数字
	var cd = str.substr(0,str.length-2);
	
	//判断长度是否到最大值
	if(cd<200)
	{	
		//将长度转为整数加2
		var cd = parseInt(cd)+2;
		
		//让进度的DIV长度变为cd
		div.style.width = cd+"px";
		
		//调用自身
		window.setTimeout("jindu()",30);
	}
}
</script>
原文:http://www.cnblogs.com/qdlj/p/6188313.html