兼容各个浏览器的缓冲圈,进度圈
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" /> <title></title> <script type="text/javascript"> window.onload = function(){ var object = document.getElementById('box') function loadImg (data){ var i = 0; setInterval(function(){ i++ if(i>data){ i=data } var imgLeft = -(i*44+(i*10))+'px' object.style.backgroundPosition = imgLeft+'\t'+'0px' object.innerHTML = i+'%'; },50) } loadImg(88) } </script> <style type="text/css"> #box{ width:44px; height:44px; line-height: 44px; text-align: center; position:absolute; left:20%; top:20%; background: url(images/investjd.png); //图片路径 http://images.cnblogs.com/cnblogs_com/xinlinux/584094/o_investjd.png } </style> </head> <body> <div id="box"> </div> </body> </html>
人如代码,规矩灵活;代码如诗,字句精伦。