bulinggitprojek
09-03-2006, 07:12 PM
hi,
this would be my first time to write a javascript. i am trying to create a slideshow and here is what i came up based from my research. this only works if my .html file and images file are on the same folder. i was hoping that i could at least have a specific folder, like "images", that would only contain all the images.
<html>
<head>
<script type="text/javascript">
<!--
var image1=new Image()
image1.src="image001.jpg"
var image2=new Image()
image2.src="image002.jpg"
var image3=new Image()
image3.src="image003.jpg"
//-->
</script>
</head>
<body>
<img src="image001.jpg" name="slideshow" width="360" height="288"/>
<script>
<!--
//variable that will increment through the images
var step=1
function slideit(){
//if browser does not support the image object, exit.
if (!document.images)
return
document.images.slideshow.src=eval("image"+step+".src")
if (step<3)
step++
else
step=1
//call function "slideit()" every 2.5 seconds
setTimeout("slideit()",2500)
}
slideit()
//-->
</script>
</body>
</html>
i hope you guys can help me here. this might be the easiest question but like what ive said, this would be my first time hehe :D
thanks,
bulinggitprojekt
this would be my first time to write a javascript. i am trying to create a slideshow and here is what i came up based from my research. this only works if my .html file and images file are on the same folder. i was hoping that i could at least have a specific folder, like "images", that would only contain all the images.
<html>
<head>
<script type="text/javascript">
<!--
var image1=new Image()
image1.src="image001.jpg"
var image2=new Image()
image2.src="image002.jpg"
var image3=new Image()
image3.src="image003.jpg"
//-->
</script>
</head>
<body>
<img src="image001.jpg" name="slideshow" width="360" height="288"/>
<script>
<!--
//variable that will increment through the images
var step=1
function slideit(){
//if browser does not support the image object, exit.
if (!document.images)
return
document.images.slideshow.src=eval("image"+step+".src")
if (step<3)
step++
else
step=1
//call function "slideit()" every 2.5 seconds
setTimeout("slideit()",2500)
}
slideit()
//-->
</script>
</body>
</html>
i hope you guys can help me here. this might be the easiest question but like what ive said, this would be my first time hehe :D
thanks,
bulinggitprojekt