日期:2014-05-16  浏览次数:20314 次

JS loading动画
<html>
<body>
	<div id="a"></div>
	<div id="b"></div>
	<script>
		var point = function(id,msg,init){
			if (typeof(init)=='undefined'){
				init=3;
			}
			this.id=id;
			this.len= init;
			var show = function(p){
				document.getElementById(id).innerHTML = msg + p;
			};
			var initp = function(n){
				var p = [];
				for(var i=0;i<n;i++){
				   p.push(".");
				}
				return p.join("");
			}
			this.start=function(){
			  var len = this.len;	
			  this.timer = setInterval(function(){
				if (init!=len){
					show(initp(++init));
				}else{
					init=1;
					show(initp(init));
					
				}
			  },300);
			  	
			};
			this.stop = function(){
			  clearInterval(this.timer);
			}
			
		}
		var p = new point("a","loading");
		p.start();
		//setTimeout(function(){p.stop()},1000);

		var q = new point("b","加载中",6);
		q.start();
		//setTimeout(function(){q.stop()},1000);
		
	</script>
</body>
</html>
1 楼 uule 2012-04-21  
有木有图片可看看。。。