<!DOCTYPE html> <html> <head> <title>change picture</title> <script type = "text/javascript"> var counter = 7000; function displayNextImage() { x = (x === images.length - 1) ? 0 : x + 1; document.getElementById("img").src = images[x]; } function displayPreviousImage() { x = (x <= 0) ? images.length - 1 : x - 1; document.getElementById("img").src = images[x]; } function startTimer() { counter = setInterval(displayNextImage, counter); var count = 60; count = count - 1; if (count == -1) { clearInterval(counter); return; } counter = count % 60; var minutes = Math.floor(count / 60); var hours = Math.floor(minutes / 60); minutes %= 60; hours %= 60; document.getElementById("startTimer").innerHTML = hours + " Hours " + minutes + " Minutes and " + seconds + " Seconds left untill the next news update."; } var images = [], x = -1; images[0] = "http://newsxpressmedia.com/files/theme/radar000116.Gif"; images[1] = "http://newsxpressmedia.com/files/theme/radarClosed.gif"; </script> <br><br><span id="startTimer"></span><br><br> </head> <body onload = "startTimer()"> <img id="img" src="http://newsxpressmedia.com/files/theme/radar000005.Gif"> <button onclick="displayPreviousImage()">Previous</button> <button onclick="displayNextImage()">Next</button> </body> </html>
seconds
startTimer()
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)