仿linux系统九宫格屏保程序:js网页版

警告:以下代码由季雨林本人探索写出,经过IE,FireFox,Chrome测试

发现Chrome(以及360的极速浏览器)浏览器对于javascript的支持明显胜于其他浏览器,请勿在电脑上长时间开启该页面,即使是js引擎强大的Chrome也会在运行半小时之后占用满内存,而其他浏览器甚至不能流畅运行,该页面制作初衷是为了仿造一种屏幕保护效果(雨林木风Linux系统:九宫格屏保),页面刚启动时的CPU占用达到顶峰时开始正常速度运行(200ms切换颜色)

代码如下(新建文本文件写入以下代码,然后把该文件的后缀名改成“.html”即可):

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="
http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Div仿屏幕保护效果 季雨林</title>
<script type="text/javascript" src="divControl.js"></script>
<script type="text/javascript">
 var colors =new Array();
  colors[0] = "#222";
  colors[1] = "#333";
  colors[2] = "#444";
  colors[3] = "#555";
  colors[4] = "#666";
  colors[5] = "#777";
  colors[6] = "#888";
  colors[7] = "#999";
  colors[8] = "#aaa";
  colors[9] = "#bbb";
 function setTimePoint(){  
  var indexArray = Math.floor((Math.random()*10));
  var indexArray2 = Math.floor((Math.random()*10));
  var idName = "id"+indexArray;
  document.getElementById(idName).style.backgroundColor = colors[indexArray2];
  //setTimeout(setTimePoint,100);
  setInterval(setTimePoint,300);
 }
</script>
<style type="text/css">
 body{
  text-align:center;
  background-color:#9CF;
 }
</style>
</head>
<body οnlοad="setTimePoint();">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
 <tr height="200px">
    <td id="id1">&nbsp;</td>
    <td id="id2">&nbsp;</td>
    <td id="id3">&nbsp;</td>
  </tr>
  <tr height="200px">
    <td id="id4">&nbsp;</td>
    <td id="id5">&nbsp;</td>
    <td id="id6">&nbsp;</td>
  </tr>
  <tr height="200px">
    <td id="id7">&nbsp;</td>
    <td id="id8">&nbsp;</td>
    <td id="id9">&nbsp;</td>
  </tr>  
</table>
</body>
</html>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值