April 29, 2019

basic javascript question

Mason Huxley @Iden

the html can bring up the picture just fine but the javascript doesn't??? why? what am i doing wrong? sg1.jpg, sg2.jpg, etc are all valid picture files in 'Image' Directory. also what would be the best way to sleep here?
Code:
<html>
<body bgcolor="White">
<script language="JavaScript">
function preloader()

{

 // counter
 var i = 0;
           

 // create object
 imageObj = new Image();


 // set image list
 images = new Array();
 images[0]="Images/sg1.jpg"
 images[1]="Images/sg2.jpg"
 images[2]="Images/sg3.jpg"
 images[3]="Images/sg4.jpg"


 // start preloading
 for(i=0; i<=3; i++) 
 {
      imageObj.src=images[i];
 }

}
// setTimeout(preloader(), 500);
</script>

<p><Center>

<br><br><br><br>

<img height="300" width="300" src="Images/sg2.jpg">
</center>
</body>
</html>

  1. 1

    the html can bring up the picture just fine but the javascript doesn't??? why? what am i doing wrong? sg1.jpg, sg2.jpg, etc are all valid picture files in 'Image' Directory. also what would be the best way to sleep here?

    Any updates??

    THanks,

    https://obdguy.com/