彩虹图片加载进度
这是彩虹图片加载进度软件编稿,是由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 imagepreload(imges) {
for(var i=0, 1=images.length; i<1; i++) {
var img = new Image():
img.onload = function();
accpomplished += 1;
if(accomplished == images.length) {
alert('图片加载完毕,点确定开始浏览');
location.href = '图片浏览器。html';
}
}
img.src = images[i];
//IE专用
img.style.display = 'none';
document.body.appendChild(img);
}
}
imagePreload(arrImgSrc);
在运用JavaScript 语言时是没有很好的变化的,用了'div' 的提示说法加载图片进行汇集,也就是把'div'元素的背景输入来形成图片加载移动的效果;IE和FF在DOM的结构上是不同的,因为FF认为firstChild是文本的节点,IE认为它切是一个元素节点,IE6在'div'元素中也是一样的;图片的汇集是由于进阶性的代码和定义函数来完成图片夹载效果。浏览器的选用也是很重要的。
本文转自huangyouliang10 51CTO博客,原文链接:http://blog.51cto.com/1572091hyl10/352161