<!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></title>
<script type="text/javascript">
var secs = 5;
function Load(){
for(var i=secs;i>=0;i--)
{
//if(parseInt(i)==0){
//i=5;
//}else{
window.setTimeout('doUpdate('+i+')', (secs-i) * 1000);
// }
}
}
function doUpdate(num){
document.getElementById('showDiv').innerHTML = '<h2>'+num+'...</h3>';
}
</script></head>
<body>
<script>
window.setTimeout("Load()",1000);
</script>
<div id="showDiv"></div>
</body>
</html>
我想知道为什么把注释的部分加上代码就有问题了,我是想在页面不断的显示5 4 3 2 1 0 5 4 3 2 1 0 5 4 3.....有大侠
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<script type="text/javascript">
var secs = 5;
function Load(){
for(var i=secs;i>=0;i--)
{
//if(parseInt(i)==0){
//i=5;
//}else{
window.setTimeout('doUpdate('+i+')', (secs-i) * 1000);
// }
}
}
function doUpdate(num){
document.getElementById('showDiv').innerHTML = '<h2>'+num+'...</h3>';
}
</script></head>
<body>
<script>
window.setTimeout("Load()",1000);
</script>
<div id="showDiv"></div>
</body>
</html>
我想知道为什么把注释的部分加上代码就有问题了,我是想在页面不断的显示5 4 3 2 1 0 5 4 3 2 1 0 5 4 3.....有大侠
解决方案 »
- 参数传递问题
- 菜鸟请教:浏览器兼容?
- UltraWebGrid如何前端綁定?
- 当用户注册时输入的EMAIL地址不合法时,我想在输入框的右边显示出来输入不合法的信息,请问这是怎么实现的呢?
- 问个firefox中的js问题
- 一段代码,希望有人帮忙解释一下
- 关于Javascript
- 通过在服务器端安装摄像头,如何使用webServer的方式在客户端看到视频录像?
- 请问:event.fromElement和event.toElement大家有没有用过,怎么用??
- 围观了!!Javascript代码调试,Google中只能输出第一个,怎么回事?
- 简单的jq表单验证用户名是否存在,用remote提交不了数据,谁可以帮我看下哪里出错了?
- 菜鸟请教关于闭包的问题
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<script type="text/javascript">
var i=5;
function Load(){
doUpdate(5);
}
function doUpdate(num){
document.getElementById('showDiv').innerHTML = '<h2>'+num+'...</h3>';
window.setTimeout(function(){doUpdate(i)},(5-i)*1000);
i=i-1;
if(i==0){
i=5;
}
}
</script></head>
<body>
<script>
window.setTimeout("Load()",1000);
</script>
<div id="showDiv"></div>
</body>
</html>
这样试试
var secs = 5;
function Load(){
for(var i=secs;i>=-1;i--)
{
//if(parseInt(i)==0){
//i=5;
//}else{
window.setTimeout('doUpdate('+i+')', (secs-i) * 1000);
// }
}
}
function doUpdate(num){
document.getElementById('showDiv').innerHTML = '<h2>'+num+'...</h3>';
if(num<0){ Load(); }
}
</script>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<div id="showDiv"></div>
<script>
var secs = 5;
function Load(){
if(secs == 0){
secs = 5;
}else{
secs--;
}
doUpdate(secs);
setTimeout(arguments.callee, 1000);
} function doUpdate(num){
document.getElementById('showDiv').innerHTML = '<h2>'+num+'...</h3>';
} setTimeout(Load, 1000);
</script>
</body>
</html>