百度首页 | 百度空间
 
查看文章
 
我跟我老婆写的第一JS
2008-04-12 16:01

<!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>无标题文档-SH!</title>
<style>
table{ border-collapse:collapse;}
td{ padding:0;}
</style>
<script language="javascript" type="text/javascript">
var beginTime=new Date().getTime();
</script>
</head>
<body>
<div id="divPageLoadTime"></div>
<div id="ta"></div>
<script>
var tr=9,tc=9,sty=0,io=0;
var ta=document.getElementById("ta")
function ty()
{
ta.innerHTML=""
var table = document.createElement("table")
table.setAttribute("border","1")
table.setAttribute("width","100%")
table.setAttribute("cellspacing","0")
table.setAttribute("cellpadding","0")
var tbody = document.createElement("tbody")
table.appendChild(tbody)
for(i=0;i<tr;i++)
{
   tbody.insertRow(i);
   for(x=0;x<tc;x++)
   {
    var t65=document.createTextNode((i+1)+"乘以"+(x+1)+"得"+(i+1)*(x+1))
    tbody.rows[i].insertCell(x);
    var d=tbody.rows[i].cells[x];
    d.appendChild(t65);
    //alert([i,x])
    var a=Math.floor(Math.random()*256);
    var b=Math.floor(Math.random()*256);
    var c=Math.floor(Math.random()*256);
    var color="rgb("+a+","+b+","+c+")";
    var oStyle = d.getAttribute("style");
    if(oStyle == "[object]")oStyle.setAttribute("cssText", "background:"+color);
    else d.setAttribute("style", "background:"+color);
   }
}
ta.appendChild(table)
sty=setTimeout(ty,1000)
//alert("p")
}
ty()
</script>
<script>
var divPageLoadTime=document.getElementById("divPageLoadTime")

endTime=new Date().getTime();
var spTime=(endTime-beginTime);
divPageLoadTime.innerHTML='页面执行时间:'+spTime+'毫秒';
</script>
</body>
</html>


类别:Js | 添加到搜藏 | 浏览() | 评论 (1)
 
最近读者:
 
网友评论:
1
2008-04-14 12:20
呵呵………………厉害哦哦!!……
 
发表评论:
姓 名:
网址或邮箱: (选填)
内 容:
验证码:
 

     

©2008 Baidu