RealisticGraphics
Sep 15th, 2000, 09:52 PM
Not difficult:
<script language="javascript">
//Set up a variable to hold the current image.
var curImg
function animate(tImg){
//Check tImg to find out what the image is displayed
if(tImg == "On.jpg"){
//Set the currently displayed image
curImg = "Off.jpg"}
else{
curImg = "On.jpg"}
//Set img1 to be the current image
document.img1.src = curImg;
//set a timer up, mine change about every second
//1000 milliseconds = about 1 second.
window.setTimeout("animate(curImg)", 1000);
}
</script>
<!-- Tell the page to animate -->
<body onLoad="animate('Off.jpg')">
<img src="" name="img1">
In addition the the above you may want to add some preloading code for the images. Let me know if you need anything else.
<script language="javascript">
//Set up a variable to hold the current image.
var curImg
function animate(tImg){
//Check tImg to find out what the image is displayed
if(tImg == "On.jpg"){
//Set the currently displayed image
curImg = "Off.jpg"}
else{
curImg = "On.jpg"}
//Set img1 to be the current image
document.img1.src = curImg;
//set a timer up, mine change about every second
//1000 milliseconds = about 1 second.
window.setTimeout("animate(curImg)", 1000);
}
</script>
<!-- Tell the page to animate -->
<body onLoad="animate('Off.jpg')">
<img src="" name="img1">
In addition the the above you may want to add some preloading code for the images. Let me know if you need anything else.