49、变换各种颜色的文本

49、变换各种颜色的文本

<html>

 

<head>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

<title>网页特效--不断变换各种颜色的文本</title>

 

<body>

 

<script LANGUAGE="JavaScript1.2">

<!-- Begin

function initArray() {

this.length = initArray.arguments.length;

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

this[i] = initArray.arguments[i];

}

}

var ctext = "欢迎光临本站";

var speed = 1000;

var x = 0;

var color = new initArray(

//改变下面的颜色。

"red",

"aqua",

"lime",

"black",

"white",

"yellow",

"#FF00FF",

"#00FFFF",

"#000000",

"#0000FF",

"#FF00FF",

"#808080",

"#008000",

"#00FF00",

"#800000",

"#000000",

"#808000",

"#800080",

"#FF0000",

"#C0C0C0",

"#008080",

"#FFFFFF",

"#FFFF00"

);

 

if(navigator.appName == "Netscape") {

document.write('<layer id="c"><center>'+ctext+'</center></layer><br>');

}

if (navigator.appVersion.indexOf("MSIE") != -1){

document.write('<div id="c"><center>'+ctext+'</center></div>');

}

function chcolor(){

if(navigator.appName == "Netscape") {

document.c.document.write('<center><font color="'+color[x]);

document.c.document.write('">'+ctext+'</font></center>');

document.c.document.close();

}

else if (navigator.appVersion.indexOf("MSIE") != -1){

document.all.c.style.color = color[x];

}

(x < color.length-1) ? x++ : x = 0;

}

setInterval("chcolor()",1000);

// End -->

</script>

 

</body>

 

</html>

 

Write a comment

Comments: 0