请问这段代码在浏览器里不能运行: <!DOCTYPE html> <html> <head> <m
请问这段代码在浏览器里不能运行:<!DOCTYPEhtml><html><head><metahttp-equiv="Content-Type"content="text...
请问这段代码在浏览器里不能运行: <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>时间</title> <script> function toDou(n) { if(n<10) { return 'imageA/0.png'+n; } else { return ' '+n; } } window.onload=function() { document.getElementById('mysj') var aImg=document.getElementsByName('img'); function tick(){ var oDate=new Date(); var str=toDou(oDate.getHours())+toDou(oDate.getMinutes())+toDou(oDate.getSeconds()); //document.write(str); for(var i=0;i<aImg.length;i++) { aImg[i].src='imageA/'+str.charAt[i]+'.png'; } } setInterval(tick,1000); tick(); }; </script> <style> #mysj{position:absolute; width:600px; height:100px; top:50px; left:30px; } </style> </head> <body> <div id="mysj"> <img src="imageA/1.png" /> <img src="imageA/3.png" /> : <img src="imageA/4.png" /> <img src="imageA/6.png" /> : <img src="imageA/5.png" /> <img src="imageA/6.png" /> </div> </body> </html>
展开
2个回答
展开全部
首先有一点建议希望你以后发的时候能把代码整理一下,以下是调整后的代码,不知道是不是你要的效果,你可以尝试下:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>时间</title>
<script>
function toDou(n) {
if(n<10){
return 'imageA/0.png'+n;
} else {
return ' '+n;
}
}
var aImg=null;
function tick(){
var oDate=new Date();
var str=toDou(oDate.getHours())+toDou(oDate.getMinutes())+toDou(oDate.getSeconds());
//
document.write(str);
for(var i=0;i<aImg.length;i++) {
aImg[i].src='imageA/'+str.charAt[i]+'.png';
}
}
window.onload=function() {
document.getElementById('mysj')
aImg = document.getElementsByName('img');
setInterval("tick()",1000);
};
</script>
<style>
#mysj{position:absolute; width:600px; height:100px; top:50px; left:30px; }
</style>
</head>
<body>
<div id="mysj">
<img src="imageA/1.png" />
<img src="imageA/3.png" />
:
<img src="imageA/4.png" />
<img src="imageA/6.png" />
:
<img src="imageA/5.png" />
<img src="imageA/6.png" />
</div>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>时间</title>
<script>
function toDou(n) {
if(n<10){
return 'imageA/0.png'+n;
} else {
return ' '+n;
}
}
var aImg=null;
function tick(){
var oDate=new Date();
var str=toDou(oDate.getHours())+toDou(oDate.getMinutes())+toDou(oDate.getSeconds());
//
document.write(str);
for(var i=0;i<aImg.length;i++) {
aImg[i].src='imageA/'+str.charAt[i]+'.png';
}
}
window.onload=function() {
document.getElementById('mysj')
aImg = document.getElementsByName('img');
setInterval("tick()",1000);
};
</script>
<style>
#mysj{position:absolute; width:600px; height:100px; top:50px; left:30px; }
</style>
</head>
<body>
<div id="mysj">
<img src="imageA/1.png" />
<img src="imageA/3.png" />
:
<img src="imageA/4.png" />
<img src="imageA/6.png" />
:
<img src="imageA/5.png" />
<img src="imageA/6.png" />
</div>
</body>
</html>
追问
谢谢你!不过还是不能运行,也不知道是怎么回事
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询