日期:2014-05-17  浏览次数:20855 次

求救,为什么这段代码运行后会出现内存不足的提示
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=gb2312">
<title>汉字时间</title>


</head>
<body>
<script defer>

function clock2(index)
{
text = "";
var hanzi = "一二三四五六七八九十";
if(index==0)
{
text = text +"零";
}
else if(index<10)
{
text = text+hanzi.substring(0+(index-1),index);
}
else if(index<20)
{
text ="十"+ text +hanzi.substring(0+(index-11),(index-10));

}
else if(index<30)
{
text ="二十"+ text+hanzi.substring(0+(index-21),(index-20));
}
else if(index<40)
{
text ="三十"+ text +hanzi.substring(0+(index-31),(index-30));

}
else if(index<50)
{
text = "四十"+text+hanzi.substring(0+(index-41),(index-40));
}
else if(index<60)
{
text ="五十"+ text +hanzi.substring(0+(index-51),(index-50));

}
return text;
}
function clock2_1()

{
clocker = document.getElementById("timer2");
aaa = new Date();
hours = aaa.getHours();
min = aaa.getMinutes();
seconds= aaa.getSeconds();

clocker.innerHTML=clock2_1(hours);

}
clock2_1();
</script>
<div id="timer"></div>
<div id="timer2"></div>
</body>
</html>

------解决方案--------------------
探讨

那么该怎么改呢?我是个新手,这个例子是仿照书本上做的,我只不过添加一些自己的元素进去就出问题了。。