如何在打开网页时创建闪烁背景

要在打开网页时创建闪烁背景,请将以下JavaScript添加到网页正文中。

<script> 

function initArray() {

this.length = initArray.arguments.length

for (var i = 0; i < this.length; i++)

this[i+1] = initArray.arguments[i]

}

var hexChars = " 0123456789ABCDEF”;

函数 Dec2Hex (Dec) {

var a = Dec % 16;

var b = (Dec - a)/16;

hex = "" + hexChars.charAt(b) + hexChars.charAt(a);

返回十六进制;

}

函数 bgChanger (开始、结束、步骤) {

步骤 = 步骤 -1 ;

redA = begin.charAt(0) + begin.charAt(1);

red_valA = parseInt(redA,'16');

redB = end.charAt(0) + end.charAt(1);

red_valB = parseInt(redB,'16');

red_int = ((red_valB - red_valA) / 步骤) * -1;

grnA = begin.charAt(2) + 开始。

grn_valA = parseInt(grnA,'16');

grnB = end.charAt(2) + end.charAt(3);

grn_valB = parseInt(grnB,'16');

grn_int = ((grn_valB - grn_valA) / 步骤) * -1;

bluA = begin.charAt(4) + begin.charAt(5);

blu_valA = parseInt(bluA,'16');

bluB = end.charAt(4) + end.charAt(5);

blu_valB = parseInt(bluB,'16');

blu_int = ((blu_valB - blu_valA) / 步骤) * -1;

步骤=2;

红色 = red_valA;

grn = grn_valA;

蓝色=蓝色_valA;

document.bgColor = 开始;

while ( 步骤 >= 步骤 ) {

red -= red_int;

red_round = Math.round(红色);

red_hex = Dec2Hex(红色);

grn -= grn_int;

grn_round = Math.round(grn);

grn_hex = Dec2Hex(grn);

蓝色 -= blu_int;

blu_round = Math.round(blu);

blu_hex = Dec2Hex(blu);

document.bgColor = red_hex + grn_hex + blu_hex;

// document.write("<br>bgcolor = " + red_hex + grn_hex + blu_hex);

步骤++;

}

文档.bgColor = 结束;

}

</script>

<script>

<!--

// 黑到黑(暂停)

bgChanger("000000","000000",25);

// 黑转红

bgChanger("000000","FF0000",25);

// 红转黑

bgChanger("FF0000","000000",25);

// 黑色到紫色

bgChanger("000000","AA00EE",25);

// 紫转黑

bgChanger("AA00EE", “000000”,25);

// 黑转蓝

bgChanger("000000","0000FF",25);

// 蓝转黑

bgChanger("0000FF","000000",25);

// 黑到白(暂停)

bgChanger("000000","FFFFFF",25);

// -->

</脚本>

以上是 如何在打开网页时创建闪烁背景 的全部内容, 来源链接: utcz.com/dzbk/943030.html

回到顶部