JavaScript关于读取路径的问题?高手们出来看下
function showImg()
{
var myTime = new Date();
var imageArray = new Array(10);
imageArray[0] = "0.jpg ";
imageArray[1] = "1.jpg ";
imageArray[2] = "2.jpg ";
imageArray[3] = "3.jpg ";
imageArray[4] = "4.jpg ";
imageArray[5] = "5.jpg ";
imageArray[6] = "6.jpg ";
imageArray[7] = "7.jpg ";
imageArray[8] = "8.jpg ";
imageArray[10] = "9.jpg ";
var year = myTime.getYear();
var month = myTime.getMonth() + 1;
var date = myTime.getDate();
var hours = myTime.getHours();
var minutes = myTime.getMinutes();
var seconds = myTime.getSeconds();
if(year < 100)
{
year = "19 " + year;
}
if(month < 10)
{
month = "0 " + month;
}
if(date < 10)
{
date = "0 " + date;
}
if(hours <= 9)
{
hours = "0 " + hours;
}
if(minutes <= 9)
{
minutes = "0 " + minutes;
}
if(seconds <= 9)
{
seconds = "0 " + seconds;
}
var theString = " " + year + month + date + hours + minutes + seconds;
document.getElementById( 'IMG0 ').src = imageArray[theString.charAt(0)];
document.getElementById( 'IMG1 ').src = imageArray[theString.charAt(1)];
document.getElementById( 'IMG2 ').src = imageArray[theString.charAt(2)];
document.getElementById( 'IMG3 ').src = imageArray[theString.charAt(3)];
document.getElementById( 'IMG4 ').src = imageArray[theString.charAt(4)];
document.getElementById( 'IMG5 ').src = imageArray[theString.charAt(5)];
document.getElementById( 'IMG6 ').src = imageArray[theString.charAt(6)];
document.getElementById( 'IMG7 ').src = imageArray[theString.charAt(7)];
document.getElementById( 'IMG8 ').src = imageArray[theString.charAt(8)];
document.getElementById( 'IMG9 ').src = imageArray[theString.charAt(9)];
document.getElementById( 'IMG10 ').src = imageArray[theString.charAt(10)];
document.getElementById( 'IMG11 ').src = imageArray[theString.charAt(11)];
document.getElementById( 'IMG12 ').src = imageArray[theString.charAt(12)];
document.getElementById( 'IMG13 ').src = imageArray[theString.charAt(13)];
setTimeout( "showImg(); ",1000);
}
<body onload= "showImg(); " leftmargin= "35px " topmargin= "20px ">
<img id= "IMG0 " style= "width:35px; height:35px; " />
<img id= "IMG1 " style= "width:35p