javascript网页背景颜色渐变效果

快乐打工仔 分类:实例代码

本章节分享一段简单代码实例,它实现了网页背景颜色渐变效果。

代码实例如下:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="author" content="http://www.51texiao.cn/" />
<title>犀牛前端部落</title>
<style>
a:hover{
  color:#00FFFF
}
</style>
<script>
var Color= new Array("ff","ee","dd","cc","bb","aa","99","88","77","66","55","44","33","22","11","00");
function fadeIn(n){
  if(n >= 1){
    document.bgColor="#" +"00"+ Color[n] +"00"; 
    n -= 1;
    setTimeout("fadeIn("+n+")", 100);
  }
  else{setTimeout('fadeOut(1)', 100);}
}
function fadeOut(n){
  if(n <=(Color.length-1)){
    document.bgColor="#" +"00"+ Color[n] +"00";
    n+=1;
    setTimeout("fadeOut("+n+")", 100)
  }
  else{
    setTimeout("fadeIn("+(Color.length-1)+")", 100);
  }
}
window.onload=function(){
  fadeIn(15)
}
</script>
</head>
<body>
<div>>http://www.pipipi.net</div>
</body>
</html>
网站出售中,有意者加微信:javadudu

回复

我来回复
  • 暂无回复内容