求助JS小错误

来源:百度知道 编辑:UC知道 时间:2024/05/25 09:31:51
小弟编了个程序:
<html>
<body>
<script language="javascript">
md=new Date();
var hours;
var mins;
hours = md.getHours();
mins = md.getMinutes();
if(hours>12) {hours-=12;}
if(hours==12) {hours=12;}
if(hours<10) {hours="0"+hours;}
if(hours==0) {hours=12;}
document.write("现在时刻",":"," ",hours,"时",mins,"分");
document.write("<img src=http://nakajun.net/images/clock/hours+mins.gif>");
</script>
</body>
</html>
很想知道怎么让倒数第4行“hours+mins.gif”的“hours+mins”自动转换为(0100~1259)的数字,小弟想了一个晚上,试了N遍也写不出来,各位大哥帮帮忙呀~~~谢了
上面的网站,大家有兴趣可以进去看看,是日本学校的JS课题(作业)资料。

想再请教一下,为什么要"+hours+mins+"呢??? 谢谢~~~

下面这一行有错:
document.write("<img src=http://nakajun.net/images/clock/hours+mins.gif>");

应该修改为:
document.write("<img src=http://nakajun.net/images/clock/"+hours+mins+".gif>");

这样就能输出0724.gif这样的图片。