1
1 Comment

basic javascript question

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/

Trending on Indie Hackers
How I grew a side project to 100k Unique Visitors in 7 days with 0 audience 47 comments Competing with Product Hunt: a month later 33 comments Why do you hate marketing? 27 comments $15k revenues in <4 months as a solopreneur 14 comments Use Your Product 13 comments How I Launched FrontendEase 13 comments