彩虹图片加载进度
彩虹圖片加載進度
????? 這是彩虹圖片加載進度軟件編稿,是由JavaScript中按JavaScript的語法中的語言代碼編寫程序開發研制而成,經過語法中編入的函數和代碼的,定義函數和編寫的代碼來改變對程序的變化形成彩虹圖片加載進度變化:
???????
???
<html>
??? <head>
??????? <style>
??????????? #bg {
??????????????? position:absolute;
??????????????? left:0;
??????????????? top:0;
??????????????? width:100%;
??????????????? height:100%;
??????????????? background:#888;
??????????????? font-size:60px;
??????????????? color:#ccc;
??????????????? text-align:center;
??????????????? //center.</width>
??????????????? //< /*默認聲音*/
??????????????? <'id' = div? i++? >連接默認形成????????????????????????????????
??????????? }
??????????? /* 彩虹進度條帶寬度形成 */
??????????? #colorLine {
???????????????? width:400px;
??????????? }
??????????? /* 組成進度條的div尺寸變化 */????
??????????? #colorLine div {
??????????????? width:5px;
??????????????? height:2px;
??????????????? float:left;
??????????????? overflow:hidden
??????????????
??????????????? display:none;
??????????? }
??????? </style>
??? </head>
<body>
??? <table id="bg">
??????? <tr height="300">
??????????? <td>
?????????????? 圖片加載進度形成變化
??????????? </td>
???????? </tr>
???????? <tr height="100">
??????????? <td align=center>
??????????????? <div id="colorLine">
??????????????? </div>
??????????? </td>
??????? </tr>
??????? <tr>
??????????? <td></td>
??????? </tr>
????? </table>
? </body>
? </html>
? <script>
? //判斷瀏覽器類別
? var IE6 = navigator.userAgent.toLowerCase().indexOf('ie')+1 &&
? /MSIE (5\.5|6\.)/i.test(navigator.userAgent);
? var CL = document.getElementById('colorLine');
???????
????? //創建彩虹條進度
????? function makeCLine() {
??????
????????? var r = 255;
????????? var g = 0;
????????? var b = 0;
????????? var step = 1;
?????????
????????? // 1. 增加綠色
????????? // 2. 減少紅色
????????? // 3. 增加藍色
????????? // 4. 減少綠色
????????? // 5. 增加×××
????????? // 6. 減少橙色
????????? // 7. 增加橙色
????????? // 8. 減少×××
????????? for(var i=0; i<80; i ++) {
????????????? //動態創建div元素進度
??????????? var node = document.createElement('div');
??????????? if(g > 255 && step == 1)
???????????? step = 2;
??????????? if(r < 0 && step == 2)
???????????? step = 3;
??????????? if(b > 255 && step == 3)?
???????????? step = 4;
??????????? //根據規則設置div的背景輸入連接
??????????? node.style.backgroundColor = 'rgb(' + r + ',' + g + ',' + b + ')';
??????????? CL.appendChild(node);
??????????? if(step == 1)
?????????????? g += 14;
??????????? if(step == 2)
?????????????? r -= 14;
??????????? if(step == 3)
?????????????? b += 14;
??????????? if(step == 4)
?????????????? g -= 14;
????????? }
????????? var oNodeL = IE6 ? CL.firstChild : CL.firstChild.nextSibling;
????????? var oNodeR = CL.lastChild;
????????
????????? //制作兩端漸變效果形成
????????? for(var i = 0; i < 50; i ++ ) {
????????????? oNodeL.style.cssText += ';opacity:'+ (0.10 * i)
??????????????? + ';filter:Alpha(Opacity='+ (0.10 * i * 200) +')';
????????????? oNodeR.style.cssText += ';opacity:'+ (0.10 * i)
??????????????? + ';filter:Alpha(Opacity=' + (0.10 * i * 200) +')';
?????????????
????????????? oNodeL = oNodel.nextSibling;
????????????? oNodeR = oNodeR.previousSibling;
????????? }
?????? }
?????
???? //移動彩虹條進度的寬度條帶
???? function makeCLMove()
???? {
??????? var colors = [];
??????? for(var i = CL.lastChild; i; i = i.previousSibling)
??????? {
?????????? if(i.style)
?????????? colors.unshift(i.style.vackgroundColor);
??????? }
??????? var flag = 1;
??????? var j = 0;
??????? //使用一個定時起來不斷地修改每個div的顏色來創造移動效果
??????? setInterval(function()
??????? {
????????? var sTempColor = CL.lastChild.style.backgroundColor;
????????? //IE與FF在DOM結構上有分歧。FF認為firstChild是一個文本節點,
????????? //而IE則認為是一個元素節點
????????? var oNodeL = IE6 ? CL.firstChild : CL.firstChild.nextSibling;
????????? for(var i = CL;.lastChild; i; i = i.previousSibling)
????????? {
??????????? if(i.previousSibling && i.previousSibling.style)
??????????? i.style.backgroundColor = i.previousSibling.style.backgroundColor;
????????? }
????????? if(j > (colors.length - 1))
???????????? flag = 0;
????????? else if(j < 1)
???????????? flag = 1;
????????? oNodeL.style.backgroundColor = flag ? colors[j ++ ] : colors[j -- ];
?????? }, 1);
???? }
?
???? makeCLine();
???? makeCLMove();
???? </script>
???? //定義要加載的圖片匯集
?????? var arrImgSrc = new Array(
?????????? "http://www.dzxw.net/pic/allimg/080619/16573710.jpg",
?????????? "http://www.dzxw.net/pic/allimg/080619/16573711.jpg",
?????????? "http://www.dzxw.net/pic/allimg/080619/16573712.jpg",
?????????? "http://www.dzxw.net/pic/allimg/080619/16573713.jpg",
?????????? "http://www.dzxp.net/pic/allimg/080619/16573714.jpg",
?????????? "http://www.dzxp.net/pic/allimg/080619/16573715.jpg",
?????????? "http://www.dzxp.net/pic/allimg/080619/16573716.jpg",
?????????? "http://www.dzxp.net/pic/allimg/080619/16573717.jpg"
?????? );
??????? //圖片已下載總數
??????? var accomplished = 0;
??????? //定義圖片組加載函數
??????? function p_w_picpathpreload(imges) {
??????????? for(var i=0, 1=p_w_picpaths.length; i<1; i++) {
??????????? var img = new Image():
??????????? img.onload = function();
??????????????? accpomplished += 1;
??????????????? if(accomplished == p_w_picpaths.length) {
??????????????????? alert('圖片加載完畢,點確定開始瀏覽');
??????????????????? location.href = '圖片瀏覽器。html';
??????????????? }
??????????? }
??????????? img.src = p_w_picpaths[i];
??????????? //IE專用
??????????? img.style.display = 'none';
??????????? document.body.appendChild(img);
??????? }
??? }
?
??? p_w_picpathPreload(arrImgSrc);
???????
????????? 在運用JavaScript 語言時是沒有很好的變化的,用了'div' 的提示說法加載圖片進行匯集,也就是把'div'元素的背景輸入來形成圖片加載移動的效果;IE和FF在DOM的結構上是不同的,因為FF認為firstChild是文本的節點,IE認為它切是一個元素節點,IE6在'div'元素中也是一樣的;圖片的匯集是由于進階性的代碼和定義函數來完成圖片夾載效果。瀏覽器的選用也是很重要的。
?
轉載于:https://blog.51cto.com/1572091hyl10/352161
總結
- 上一篇: 用perl 实现 svn 差异备份
- 下一篇: 文件压缩于打包